mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-21 06:37:09 +08:00
source_script: Use command for external commands
users might have functions in interactive shells shadowing system commands.
This commit is contained in:
parent
27c8a32077
commit
11080e5c37
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user