mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-06 10:08:47 +00:00
List time as builtin, support time --help
`a=b time foo` will no longer call an external `time` command
(like it does in bash).
Fixes #6598
(cherry picked from commit 7ef7f93a90
)
This commit is contained in:
parent
f3eb996b45
commit
26949fa865
3 changed files with 6 additions and 15 deletions
|
@ -394,6 +394,7 @@ static const builtin_data_t builtin_datas[] = {
|
||||||
{L"string", &builtin_string, N_(L"Manipulate strings")},
|
{L"string", &builtin_string, N_(L"Manipulate strings")},
|
||||||
{L"switch", &builtin_generic, N_(L"Conditionally execute a block of commands")},
|
{L"switch", &builtin_generic, N_(L"Conditionally execute a block of commands")},
|
||||||
{L"test", &builtin_test, N_(L"Test a condition")},
|
{L"test", &builtin_test, N_(L"Test a condition")},
|
||||||
|
{L"time", &builtin_generic, N_(L"Measure how long a command or block takes")},
|
||||||
{L"true", &builtin_true, N_(L"Return a successful result")},
|
{L"true", &builtin_true, N_(L"Return a successful result")},
|
||||||
{L"ulimit", &builtin_ulimit, N_(L"Set or get the shells resource usage limits")},
|
{L"ulimit", &builtin_ulimit, N_(L"Set or get the shells resource usage limits")},
|
||||||
{L"wait", &builtin_wait, N_(L"Wait for background processes completed")},
|
{L"wait", &builtin_wait, N_(L"Wait for background processes completed")},
|
||||||
|
|
|
@ -397,16 +397,12 @@ RESOLVE(optional_background) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RESOLVE(optional_time) {
|
RESOLVE(optional_time) {
|
||||||
UNUSED(token2);
|
if (token1.keyword == parse_keyword_time && !token2.is_help_argument) {
|
||||||
|
*out_tag = parse_optional_time_time;
|
||||||
switch (token1.keyword) {
|
return production_for<time>();
|
||||||
case parse_keyword_time:
|
|
||||||
*out_tag = parse_optional_time_time;
|
|
||||||
return production_for<time>();
|
|
||||||
default:
|
|
||||||
*out_tag = parse_optional_time_no_time;
|
|
||||||
return production_for<empty>();
|
|
||||||
}
|
}
|
||||||
|
*out_tag = parse_optional_time_no_time;
|
||||||
|
return production_for<empty>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const production_element_t *parse_productions::production_for_token(parse_token_type_t node_type,
|
const production_element_t *parse_productions::production_for_token(parse_token_type_t node_type,
|
||||||
|
|
|
@ -32,12 +32,6 @@ true && time a=b not builtin true | true
|
||||||
#CHECKERR: {{.*}}
|
#CHECKERR: {{.*}}
|
||||||
#CHECKERR: {{.*}}
|
#CHECKERR: {{.*}}
|
||||||
|
|
||||||
PATH= time true
|
|
||||||
#CHECKERR: fish: Unknown command: time
|
|
||||||
#CHECKERR: {{.*}}
|
|
||||||
#CHECKERR: PATH= time true
|
|
||||||
#CHECKERR: ^
|
|
||||||
|
|
||||||
not time true
|
not time true
|
||||||
#CHECKERR: ___{{.*}}
|
#CHECKERR: ___{{.*}}
|
||||||
#CHECKERR: {{.*}}
|
#CHECKERR: {{.*}}
|
||||||
|
|
Loading…
Reference in a new issue