mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Pass location of the *command* node without decorators
Fixes error location for unknown commands
This commit is contained in:
parent
150409eabd
commit
a4fd3c194e
3 changed files with 14 additions and 9 deletions
|
@ -736,7 +736,7 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
|
|||
// ELOOP
|
||||
// ENAMETOOLONG
|
||||
return this->report_error(
|
||||
STATUS_NOT_EXECUTABLE, statement,
|
||||
STATUS_NOT_EXECUTABLE, statement.command,
|
||||
_(L"Unknown command. '%ls' exists but is not an executable file."), cmd);
|
||||
}
|
||||
|
||||
|
@ -791,7 +791,7 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
|
|||
|
||||
// Here we want to report an error (so it shows a backtrace).
|
||||
// If the handler printed text, that's already shown, so error will be empty.
|
||||
return this->report_error(STATUS_CMD_UNKNOWN, statement, error.c_str());
|
||||
return this->report_error(STATUS_CMD_UNKNOWN, statement.command, error.c_str());
|
||||
}
|
||||
|
||||
end_execution_reason_t parse_execution_context_t::expand_command(
|
||||
|
@ -825,7 +825,7 @@ end_execution_reason_t parse_execution_context_t::expand_command(
|
|||
// Complain if the resulting expansion was empty, or expanded to an empty string.
|
||||
// For no-exec it's okay, as we can't really perform the expansion.
|
||||
if (out_cmd->empty() && !no_exec()) {
|
||||
return this->report_error(STATUS_ILLEGAL_CMD, statement,
|
||||
return this->report_error(STATUS_ILLEGAL_CMD, statement.command,
|
||||
_(L"The expanded command was empty."));
|
||||
}
|
||||
return end_execution_reason_t::ok;
|
||||
|
|
|
@ -4,22 +4,22 @@ $fish -c "nonexistent-command-1234 banana rama"
|
|||
#CHECKERR: fish: Unknown command: nonexistent-command-1234
|
||||
#CHECKERR: fish:
|
||||
#CHECKERR: nonexistent-command-1234 banana rama
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~^
|
||||
$fish -C 'function fish_command_not_found; echo cmd-not-found; end' -ic "nonexistent-command-1234 1 2 3 4"
|
||||
#CHECKERR: cmd-not-found
|
||||
#CHECKERR: fish:
|
||||
#CHECKERR: nonexistent-command-1234 1 2 3 4
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~^
|
||||
$fish -C 'function fish_command_not_found; echo command-not-found $argv; end' -c "nonexistent-command-abcd foo bar baz"
|
||||
#CHECKERR: command-not-found nonexistent-command-abcd foo bar baz
|
||||
#CHECKERR: fish:
|
||||
#CHECKERR: nonexistent-command-abcd foo bar baz
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~^
|
||||
|
||||
$fish -C 'functions --erase fish_command_not_found' -c 'nonexistent-command apple friday'
|
||||
#CHECKERR: fish: Unknown command: nonexistent-command
|
||||
#CHECKERR: nonexistent-command apple friday
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: ^~~~~~~~~~~~~~~~~~^
|
||||
|
||||
command -v nonexistent-command-1234
|
||||
echo $status
|
||||
|
@ -30,14 +30,14 @@ echo $status
|
|||
# CHECKERR: {{.*}}: Unknown command: '{ echo; echo }'
|
||||
# CHECKERR: {{.*}}: '{ ... }' is not supported for grouping commands. Please use 'begin; ...; end'
|
||||
# CHECKERR: { echo; echo }
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: ^~~~~~~~~~~~~^
|
||||
|
||||
set -g PATH .
|
||||
echo banana > foobar
|
||||
foobar --banana
|
||||
# CHECKERR: checks/command-not-found.fish (line {{\d+}}): Unknown command. './foobar' exists but is not an executable file.
|
||||
# CHECKERR: foobar --banana
|
||||
# CHECKERR: ^
|
||||
# CHECKERR: ^~~~~^
|
||||
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -47,4 +47,9 @@ echo 'echo foo; and $status' | $fish --no-config
|
|||
echo 'set -l status_cmd true; if $status_cmd; echo Heck yes this is true; end' | $fish --no-config
|
||||
#CHECK: Heck yes this is true
|
||||
|
||||
foo=bar $NONEXISTENT -c 'set foo 1 2 3; set --show foo'
|
||||
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
||||
#CHECKERR: foo=bar $NONEXISTENT -c 'set foo 1 2 3; set --show foo'
|
||||
#CHECKERR: ^~~~~~~~~~~^
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue