Make __fish_describe_command stop barfing on /

Prior to this fix, __fish_describe_command would error if the
input contained any special characters, because it would be interpolated
into a regex. Hack in a guard to do nothing if the input contains
anything other than [a-zA-Z0-9_ ]
This commit is contained in:
ridiculousfish 2018-07-09 23:13:53 -07:00
parent 87f646d84d
commit 6a6ffe68cb

View file

@ -3,6 +3,11 @@
# #
function __fish_describe_command -d "Command used to find descriptions for commands" function __fish_describe_command -d "Command used to find descriptions for commands"
# We're going to try to build a regex out of $argv inside awk.
# Make sure $argv has no special characters.
# TODO: stop interpolating argv into regex, and remove this hack.
string match --quiet --regex '^[a-zA-Z0-9_ ]+$' -- "$argv"
or return
apropos $argv 2>/dev/null | awk -v FS=" +- +" '{ apropos $argv 2>/dev/null | awk -v FS=" +- +" '{
split($1, names, ", "); split($1, names, ", ");
for (name in names) for (name in names)