mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 00:47:30 +00: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:
parent
3c7019b335
commit
535845861a
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue