mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Don't set error offset for $status
This would break the location of any prior errors without doing anything of value. E.g. ```fish echo foo | exec grep # this exec is not allowed! $status somethingelse # The error might be found here! ``` Would apply the offset of `$status` to the offset of `exec`, locating the error for `exec` somewhere after $status!
This commit is contained in:
parent
d619d79117
commit
6774a514fa
|
@ -1111,7 +1111,6 @@ static bool detect_errors_in_decorated_statement(const wcstring &buff_src,
|
|||
// We see this surprisingly regularly.
|
||||
const wcstring &com = dst.command.source(buff_src, storage);
|
||||
if (com == L"$status") {
|
||||
parse_error_offset_source_start(parse_errors, source_start);
|
||||
errored =
|
||||
append_syntax_error(parse_errors, source_start,
|
||||
_(L"$status is not valid as a command. See `help conditions`"));
|
||||
|
|
12
tests/checks/syntax-error-location.fish
Normal file
12
tests/checks/syntax-error-location.fish
Normal file
|
@ -0,0 +1,12 @@
|
|||
#RUN: %fish -C 'set -g fish %fish' %s
|
||||
|
||||
# A $status used as a command should not impact the location of other errors.
|
||||
echo 'echo foo | exec grep # this exec is not allowed!
|
||||
|
||||
$status
|
||||
|
||||
# The error might be found here!' | $fish 2>| string replace -r '(.*)' '<$1>'
|
||||
|
||||
# CHECK: <fish: The 'exec' command can not be used in a pipeline>
|
||||
# CHECK: <echo foo | exec grep # this exec is not allowed!>
|
||||
# CHECK: < ^>
|
Loading…
Reference in New Issue
Block a user