Update the PATH checking code to work in batch mode

darcs-hash:20060518133726-ac50b-81759f01565fdfdb85c042c1db1b766a9a6adcda.gz
This commit is contained in:
axel 2006-05-18 23:37:26 +10:00
parent 763a6b8351
commit db459f869a

View File

@ -40,12 +40,14 @@ if test "$USER" = root
set path_list $path_list /sbin /usr/sbin /usr/local/sbin
end
for i in $path_list
set -l regex "^$i\(\|/*\)\$"
if not printf "%s\n" $PATH|grep $regex >/dev/null
if test -d $i
set PATH $PATH $i
end
# Make a regular expressin that matches any component in the PATH. A
# trailing slash is ok. The sed call is to remove the last '\|'.
set -l path_regexp \\\((printf "^%s\\(\\|/\\)\$\\|" $PATH | sed -e "s/..\$//")\\\)
for i in (printf "%s\n" $path_list|grep -v $path_regexp)
if test -d $i
set PATH $PATH $i
end
end