From 6a6ffe68cb5d215ac0dc84f500ce6c2dba9e30e9 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 9 Jul 2018 23:13:53 -0700 Subject: [PATCH] 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_ ] --- share/functions/__fish_describe_command.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/functions/__fish_describe_command.fish b/share/functions/__fish_describe_command.fish index 43936c4be..d102f0e71 100644 --- a/share/functions/__fish_describe_command.fish +++ b/share/functions/__fish_describe_command.fish @@ -3,6 +3,11 @@ # 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=" +- +" '{ split($1, names, ", "); for (name in names)