mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 13:23:09 +00:00
Command-not-found: Warn if a file exists but isn't executable
This simply adds a nice error so you can better see if your command isn't available because it's not executable. Fixes #8804.
This commit is contained in:
parent
dc4e88d7b4
commit
71cfd25c1d
3 changed files with 23 additions and 0 deletions
|
@ -23,8 +23,15 @@ end
|
|||
#
|
||||
function __fish_default_command_not_found_handler
|
||||
printf "fish: Unknown command: %s\n" (string escape -- $argv[1]) >&2
|
||||
for file in $PATH/$argv[1]
|
||||
if test -e $file -a ! -x $file
|
||||
printf (_ "fish: %s exists but isn't executable\n") (string escape -- $file) >&2
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if not status --is-interactive
|
||||
# Hook up the default as the command_not_found handler
|
||||
# if we are not interactive to avoid custom handlers.
|
||||
|
|
|
@ -13,6 +13,12 @@ end
|
|||
|
||||
function __fish_default_command_not_found_handler
|
||||
printf "fish: Unknown command: %s\n" (string escape -- $argv[1]) >&2
|
||||
for file in $PATH/$argv[1]
|
||||
if test -e $file -a ! -x $file
|
||||
printf (_ "fish: %s exists but isn't executable\n") (string escape -- $file) >&2
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# If an old handler already exists, defer to that.
|
||||
|
|
|
@ -32,4 +32,14 @@ echo $status
|
|||
# CHECKERR: { echo; echo }
|
||||
# CHECKERR: ^
|
||||
|
||||
set -g PATH .
|
||||
echo banana > foobar
|
||||
foobar --banana
|
||||
# CHECKERR: fish: Unknown command: foobar
|
||||
# CHECKERR: fish: ./foobar exists but isn't executable
|
||||
# CHECKERR: checks/command-not-found.fish (line 37):
|
||||
# CHECKERR: foobar --banana
|
||||
# CHECKERR: ^
|
||||
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue