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

2014-06-10 Thread Dale R. Worley
> From: Dan Douglas 
> 
> On Mon, Jun 9, 2014 at 7:51 PM, Dale R. Worley  wrote:
> > But if I add braces around the condition, 'time' is recognized:
> 
> That's not too surprising. That "!" is unaffected is. "if ! ! time :;
> then ..." is an equivalent but working pipeline. "if time { :; };"
> should also be valid but time isn't recognized.

It might not be surprising, but it's incorrect according to the manual
page.

That "! !" works at all is astonishing, because the syntax in the
manual page seems to show that only one "!" is allowed:

  [time [-p]] [ ! ] command [ [|⎪|&] command2 ... ]

Part of the problem is that the manual page defines "simple command",
"pipeline", "list", and "complex command", but it doesn't seem to
define "command", and it is "command" which appears as a component in
the definitions of "pipeline", "list", and "complex command".

E.g., in the above syntax for pipeline, is "command" itself allowed to
be a pipeline (and so it can start with "!") or must it be a simple
command (in which case it can't)?

In addition, the rule for reserved words is:

   Reserved words are words that have a special meaning to the shell.  The
   following words are recognized as reserved when unquoted and either the
   first  word  of a simple command (see SHELL GRAMMAR below) or the third
   word of a case or for command:

But none of the reserved words *are* the first word of a simple
command; they start (and thus are part of) other constructions.  I
think the meaning is "in a location where a simple command could
start", bit it would help if the documentation was clearer.

Dale



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

2014-06-10 Thread Andreas Schwab
wor...@alum.mit.edu (Dale R. Worley) writes:

> Part of the problem is that the manual page defines "simple command",
> "pipeline", "list", and "complex command", but it doesn't seem to
> define "command", and it is "command" which appears as a component in
> the definitions of "pipeline", "list", and "complex command".

A command can be either a simple command, a compound command, or a
function definition, but not a pipeline or a list.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



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

2014-06-10 Thread Dan Douglas
On Tue, Jun 10, 2014 at 8:39 AM, Dale R. Worley  wrote:
>> From: Dan Douglas 
>>
>> On Mon, Jun 9, 2014 at 7:51 PM, Dale R. Worley  wrote:
>> > But if I add braces around the condition, 'time' is recognized:
>>
>> That's not too surprising. That "!" is unaffected is. "if ! ! time :;
>> then ..." is an equivalent but working pipeline. "if time { :; };"
>> should also be valid but time isn't recognized.
>
> It might not be surprising, but it's incorrect according to the manual
> page.
>
> That "! !" works at all is astonishing, because the syntax in the
> manual page seems to show that only one "!" is allowed:

Chet explained the actual workings pretty well if you're interested:

https://lists.gnu.org/archive/html/bug-bash/2012-10/msg00062.html

The manual is incomplete but I think the real behavior makes sense.
The "if time" case you noticed is still pretty clearly buggy.