From db459f869accd75ee74a279772daaa212d271687 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 18 May 2006 23:37:26 +1000 Subject: [PATCH] Update the PATH checking code to work in batch mode darcs-hash:20060518133726-ac50b-81759f01565fdfdb85c042c1db1b766a9a6adcda.gz --- share/fish.in | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/share/fish.in b/share/fish.in index 9418cbcf8..816771b3f 100644 --- a/share/fish.in +++ b/share/fish.in @@ -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