builtin time: print help on invalid syntax

I always mix up the order with variable assignments.
This commit is contained in:
Johannes Altmanninger 2020-10-26 19:13:34 +01:00
parent 9eb2649319
commit 5ff2d38d4c
2 changed files with 10 additions and 1 deletions

View File

@ -39,3 +39,12 @@ Example
Executed in 3,01 secs fish external
usr time 9,16 millis 2,94 millis 6,23 millis
sys time 0,23 millis 0,00 millis 0,23 millis
Inline variable assignments need to follow the ``time`` keyword::
>_ time a_moment=1.5m sleep $a_moment
________________________________________________________
Executed in 90.00 secs fish external
usr time 4.62 millis 4.62 millis 0.00 millis
sys time 2.35 millis 0.41 millis 1.95 millis

View File

@ -217,7 +217,7 @@ static maybe_t<int> builtin_generic(parser_t &parser, io_streams_t &streams, wch
// Hackish - if we have no arguments other than the command, we are a "naked invocation" and we
// just print help.
if (argc == 1) {
if (argc == 1 || wcscmp(cmd, L"time") == 0) {
builtin_print_help(parser, streams, cmd);
return STATUS_INVALID_ARGS;
}