fix: use string check to determine if filename is a fish file; fix #459

Bug was introduced in 7850f78e8a.

When removing a file don't use `functions -q $filename` as a loose
check for a .fish file. Use a string match instead.

`functions -q $filename` will cause the function defined in the file
to be autoloaded (if it wasn't already) which can cause trouble with
some "dubious" packages that run arbitrary code in function files.
This commit is contained in:
Jorge Bucaran 2018-10-07 12:34:49 +09:00
parent 60d3c4c9c3
commit 2a6c36b8a9
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30

View file

@ -324,16 +324,13 @@ function _fisher_pkg_uninstall -a pkg
set -l filename (echo "$target" | command sed 's|.fish||') set -l filename (echo "$target" | command sed 's|.fish||')
switch $source switch $source
case $pkg/conf.d\* case $pkg/conf.d\*
if test "$filename.fish" = "$target" test "$filename.fish" = "$target"; and emit "$filename"_uninstall
emit "$filename"_uninstall
end
set target conf.d/$target set target conf.d/$target
case $pkg/completions\* case $pkg/completions\*
if functions -q "$filename" test "$filename.fish" = "$target"; and complete -ec $filename
complete -ec $filename
end
set target completions/$target set target completions/$target
case $pkg/{,functions}\* case $pkg/{,functions}\*
test "$filename.fish" = "$target"; and functions -e $filename
switch $target switch $target
case uninstall.fish case uninstall.fish
source $source source $source
@ -343,9 +340,6 @@ function _fisher_pkg_uninstall -a pkg
case \* case \*
set target functions/$target set target functions/$target
end end
if functions -q "$filename"
functions -e $filename
end
end end
command rm -f $fisher_path/$target command rm -f $fisher_path/$target
end end