You use somthing like this (in some places):
local currentRoot=$(mount | grep -w / | cut -f1 -d" ")
This will not result in the desired result, if "mount" will return a line like:
//\/\ on /mnt/\ type cifs ....
(That are my mounts of Network storage)
In generell I wouldn't use grep with option -w if the search string isn't a word.
This will result in an incorrect result if there is a "/" followed by another char that isn't a alphanum or underscore. (here the two // will form a match)
One solution might be:
local currentRoot=$(mount | grep " / " | cut -f1 -d" ")
but this is only for this special case, So I would sugest this:
local currentRoot=$(mount | sed -n "/\W\/\W/s/(^[^ \t])./\1/p")
This is "smaller/faster", because it use only one external function (sed) instead of grep and cut.
And You use this kind of search at other places, too.
You use somthing like this (in some places): local currentRoot=$(mount | grep -w / | cut -f1 -d" ") This will not result in the desired result, if "mount" will return a line like: //\/\ on /mnt/\ type cifs ....
(That are my mounts of Network storage)
In generell I wouldn't use grep with option -w if the search string isn't a word.
This will result in an incorrect result if there is a "/" followed by another char that isn't a alphanum or underscore. (here the two // will form a match)
One solution might be: local currentRoot=$(mount | grep " / " | cut -f1 -d" ")
but this is only for this special case, So I would sugest this: local currentRoot=$(mount | sed -n "/\W\/\W/s/(^[^ \t])./\1/p")
This is "smaller/faster", because it use only one external function (sed) instead of grep and cut. And You use this kind of search at other places, too.