mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 19:41:14 -03:00
__fish_describe_command: print only exact match and exit
Mimic the behavior of Linux's `apropos -e` and ~BSD's `apropos -f` with the awk script by disallowing trailing characters in the name of the manpage as compared to the original input string. Apart from being faster (by aborting earlier and stopping `apropos` by breaking the pipe after the first match), it's also more correct.
This commit is contained in:
@@ -32,10 +32,11 @@ function __fish_describe_command -d "Command used to find descriptions for comma
|
||||
apropos $argv 2>/dev/null | awk -v FS=" +- +" '{
|
||||
split($1, names, ", ");
|
||||
for (name in names)
|
||||
if (names[name] ~ /^'"$argv_regex"'.* *\([18]\)/ ) {
|
||||
if (names[name] ~ /^'"$argv_regex"'[^A-z._-]* *\([18]\)/ ) {
|
||||
sub( "( |\t)*\\\([18]\\\)", "", names[name] );
|
||||
sub( " \\\[.*\\\]", "", names[name] );
|
||||
print names[name] "\t" $2;
|
||||
exit;
|
||||
}
|
||||
}'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user