bug-bash
[Top][All Lists]
Advanced

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

Re: style of assignment to variable changes command selection


From: Chet Ramey
Subject: Re: style of assignment to variable changes command selection
Date: Sat, 08 Mar 2008 12:33:48 -0500
User-agent: Thunderbird 2.0.0.12 (Macintosh/20080213)

Doug McIlroy wrote:
These two bash sequences are not equivalent.
My intuition and the bash man page tell me they should be the same.

  % export X=x; time --version; unset X
  -bash: --version: command not found

  % unset X; X=x time --version
  GNU time 1.7

They are not the same, and should not be treated identically.  Bash
implements `time' as a reserved word, not a builtin.  Reserved words
are recognized by the grammar only in specific circumstances, and
following an assignment statement isn't one of them.

I implemented it as a reserved word to allow pipelines, and to a
lesser extent, shell builtins, to be timed.  There's really no reason
to ever implement it as a regular builtin -- people just don't time
builtins very often, and that's the only thing making it a builtin
would buy you.

Bash's implementation of time conforms to Posix, which explicitly
allows it to be a reserved word.  However, it is possible, and fairly
easy, to configure bash without support for command timing.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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