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||')
switch $source
case $pkg/conf.d\*
if test "$filename.fish" = "$target"
emit "$filename"_uninstall
end
test "$filename.fish" = "$target"; and emit "$filename"_uninstall
set target conf.d/$target
case $pkg/completions\*
if functions -q "$filename"
complete -ec $filename
end
test "$filename.fish" = "$target"; and complete -ec $filename
set target completions/$target
case $pkg/{,functions}\*
test "$filename.fish" = "$target"; and functions -e $filename
switch $target
case uninstall.fish
source $source
@ -343,9 +340,6 @@ function _fisher_pkg_uninstall -a pkg
case \*
set target functions/$target
end
if functions -q "$filename"
functions -e $filename
end
end
command rm -f $fisher_path/$target
end