Commit 11080e5c authored by Jörg Thalheim's avatar Jörg Thalheim

source_script: Use command for external commands

users might have functions in interactive shells shadowing system commands.
parent 27c8a320
......@@ -53,8 +53,8 @@ function source_script --description 'Source sh/csh file'
if test "$ext"
eval "exec $exe -c '$source $argv; exec fish'"
else
set -l f1 (mktemp -t tmp.XXXXXXXXXX)
set -l f2 (mktemp -t tmp.XXXXXXXXXX)
set -l f1 (command mktemp -t tmp.XXXXXXXXXX)
set -l f2 (command mktemp -t tmp.XXXXXXXXXX)
eval $exe -c "'env | sort > $f1; $source $argv; env | sort > $f2'"
set -l filter "(^[^\+-]|^\+\+\+|^---|^[\+-]_|^[\+-]PIPESTATUS|^[\+-]COLUMNS)"
......@@ -62,7 +62,7 @@ function source_script --description 'Source sh/csh file'
set -l IFS '='
set -l diffopts --old-line-format '-=%L' --new-line-format '+=%L' --unchanged-line-format ''
diff $diffopts $f1 $f2 | grep -vE $filter | while read -l state var value
command diff $diffopts $f1 $f2 | command grep -vE $filter | while read -l state var value
switch $state$var
case -PATH
continue
......@@ -75,23 +75,20 @@ function source_script --description 'Source sh/csh file'
echo "Unable to add '$pt' to \$PATH. Check existance."
continue
end
#echo set -gx PATH $PATH $pt
set -gx PATH $PATH $pt > /dev/null
end
case '-*'
#echo unset $var
set -e $var
case '+*'
eval set -gx $var (echo $value | sed $pattern)
#echo Set $var to: (echo $value | sed $pattern)
eval set -gx $var (echo $value | command sed $pattern)
case '*'
echo Source error! Invalid case "'$state$var'"
end
end
rm $f1 $f2 > /dev/null
command rm $f1 $f2 > /dev/null
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment