Commit ef9983d4 authored by Bruno's avatar Bruno

Merge pull request #129 from Mic92/patch-1

source_script: Use command for external commands
parents 27c8a320 11080e5c
...@@ -53,8 +53,8 @@ function source_script --description 'Source sh/csh file' ...@@ -53,8 +53,8 @@ function source_script --description 'Source sh/csh file'
if test "$ext" if test "$ext"
eval "exec $exe -c '$source $argv; exec fish'" eval "exec $exe -c '$source $argv; exec fish'"
else else
set -l f1 (mktemp -t tmp.XXXXXXXXXX) set -l f1 (command mktemp -t tmp.XXXXXXXXXX)
set -l f2 (mktemp -t tmp.XXXXXXXXXX) set -l f2 (command mktemp -t tmp.XXXXXXXXXX)
eval $exe -c "'env | sort > $f1; $source $argv; env | sort > $f2'" eval $exe -c "'env | sort > $f1; $source $argv; env | sort > $f2'"
set -l filter "(^[^\+-]|^\+\+\+|^---|^[\+-]_|^[\+-]PIPESTATUS|^[\+-]COLUMNS)" set -l filter "(^[^\+-]|^\+\+\+|^---|^[\+-]_|^[\+-]PIPESTATUS|^[\+-]COLUMNS)"
...@@ -62,7 +62,7 @@ function source_script --description 'Source sh/csh file' ...@@ -62,7 +62,7 @@ function source_script --description 'Source sh/csh file'
set -l IFS '=' set -l IFS '='
set -l diffopts --old-line-format '-=%L' --new-line-format '+=%L' --unchanged-line-format '' 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 switch $state$var
case -PATH case -PATH
continue continue
...@@ -75,23 +75,20 @@ function source_script --description 'Source sh/csh file' ...@@ -75,23 +75,20 @@ function source_script --description 'Source sh/csh file'
echo "Unable to add '$pt' to \$PATH. Check existance." echo "Unable to add '$pt' to \$PATH. Check existance."
continue continue
end end
#echo set -gx PATH $PATH $pt
set -gx PATH $PATH $pt > /dev/null set -gx PATH $PATH $pt > /dev/null
end end
case '-*' case '-*'
#echo unset $var
set -e $var set -e $var
case '+*' case '+*'
eval set -gx $var (echo $value | sed $pattern) eval set -gx $var (echo $value | command sed $pattern)
#echo Set $var to: (echo $value | sed $pattern)
case '*' case '*'
echo Source error! Invalid case "'$state$var'" echo Source error! Invalid case "'$state$var'"
end end
end end
rm $f1 $f2 > /dev/null command rm $f1 $f2 > /dev/null
end end
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