From 5ff2d38d4c16ed499c006b4d7258e6664436b7d2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 26 Oct 2020 19:13:34 +0100 Subject: [PATCH] builtin time: print help on invalid syntax I always mix up the order with variable assignments. --- doc_src/cmds/time.rst | 9 +++++++++ src/builtin.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc_src/cmds/time.rst b/doc_src/cmds/time.rst index f6e8778bb..8c3a3de38 100644 --- a/doc_src/cmds/time.rst +++ b/doc_src/cmds/time.rst @@ -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 diff --git a/src/builtin.cpp b/src/builtin.cpp index db324cd12..4c2ba7ff8 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -217,7 +217,7 @@ static maybe_t 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; }