mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Emit an error if time is used past the first command in a pipeline
Fixes #8841
This commit is contained in:
parent
247d4b2c8f
commit
a960a3cde6
3 changed files with 15 additions and 0 deletions
|
@ -36,6 +36,7 @@ Interactive improvements
|
||||||
- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`).
|
- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`).
|
||||||
- ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD and NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`).
|
- ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD and NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`).
|
||||||
- The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`).
|
- The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`).
|
||||||
|
- ``time`` now emits an error if used after the first command in a pipeline (:issue:`8841`).
|
||||||
|
|
||||||
New or improved bindings
|
New or improved bindings
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
/// Error message for arguments to 'end'
|
/// Error message for arguments to 'end'
|
||||||
#define END_ARG_ERR_MSG _(L"'end' does not take arguments. Did you forget a ';'?")
|
#define END_ARG_ERR_MSG _(L"'end' does not take arguments. Did you forget a ';'?")
|
||||||
|
|
||||||
|
/// Error message when 'time' is in a pipeline.
|
||||||
|
#define TIME_IN_PIPELINE_ERR_MSG _(L"The 'time' command may only be at the beginning of a pipeline")
|
||||||
|
|
||||||
/// Maximum length of a variable name to show in error reports before truncation
|
/// Maximum length of a variable name to show in error reports before truncation
|
||||||
static constexpr int var_err_len = 16;
|
static constexpr int var_err_len = 16;
|
||||||
|
|
||||||
|
@ -1123,6 +1126,11 @@ static bool detect_errors_in_decorated_statement(const wcstring &buff_src,
|
||||||
errored = append_syntax_error(parse_errors, source_start, INVALID_PIPELINE_CMD_ERR_MSG,
|
errored = append_syntax_error(parse_errors, source_start, INVALID_PIPELINE_CMD_ERR_MSG,
|
||||||
command.c_str());
|
command.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Similarly for time (#8841).
|
||||||
|
if (command == L"time") {
|
||||||
|
errored = append_syntax_error(parse_errors, source_start, TIME_IN_PIPELINE_ERR_MSG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $status specifically is invalid as a command,
|
// $status specifically is invalid as a command,
|
||||||
|
|
|
@ -11,6 +11,12 @@ $status
|
||||||
# CHECK: <echo foo | exec grep # this exec is not allowed!>
|
# CHECK: <echo foo | exec grep # this exec is not allowed!>
|
||||||
# CHECK: < ^>
|
# CHECK: < ^>
|
||||||
|
|
||||||
|
echo 'true | time false' | $fish 2>| string replace -r '(.*)' '<$1>'
|
||||||
|
# CHECK: <fish: The 'time' command may only be at the beginning of a pipeline>
|
||||||
|
# CHECK: <true | time false>
|
||||||
|
# CHECK: < ^>
|
||||||
|
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
(true one)
|
(true one)
|
||||||
|
|
Loading…
Reference in a new issue