bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'time' not recognized as reserved when first word after 'if'


From: Dale R. Worley
Subject: 'time' not recognized as reserved when first word after 'if'
Date: Mon, 9 Jun 2014 20:51:12 -0400

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' 
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux hobgoblin.ariadne.com 3.14.4-100.fc19.x86_64 #1 SMP Tue May 
13 15:00:26 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.3
Patch Level: 0
Release Status: release

Description:

It appears that the reserved word 'time' is not recognized as such if
it is the first word of the command following 'if'.  Instead,
/usr/bin/time is executed, producing different output.

Repeat-By:

The reserved word 'time' is to be recognized in certain positions.  In
particular, it is to be put at the beginning of a *pipeline*, which
includes the beginnings of *lists*.  It does not include any position
in a simple command other than the first word; in particular, it
cannot be after a variable assignment.  This is illustrated by:

$ time true

real    0m0.000s <----- built-in output
user    0m0.000s
sys     0m0.000s
$ X=x time true
v----- /usr/bin/time output
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 308maxresident)k
0inputs+0outputs (0major+111minor)pagefaults 0swaps
$ time X=x true

real    0m0.000s <----- built-in output
user    0m0.000s
sys     0m0.000s

However, 'time' is not recognized immediately after 'if', despite that
that position is the beginning of a list, a pipeline, a command, and a
simple command:  (The beginning of a pipeline being where the reserved
word 'time' is syntactically allowed, and the beginning of a simple
command being where 'time' is recognized as a reserved word.)

$ if time true ; then echo true ; fi
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 308maxresident)k
0inputs+0outputs (0major+112minor)pagefaults 0swaps
true

But if I add braces around the condition, 'time' is recognized:
(Despite that the condition following 'if' and the contents following
'{' are both 'list'.)

$ if { time true ; } ; then echo true ; fi

real    0m0.000s
user    0m0.000s
sys     0m0.000s
true

Fix:

Unknown.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]