tech-userlevel archive

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

Re: sh -e changes broke pkgsrc



 >> Strictly speaking you right.  Though, this is nonsense IMHO. 

> You might want to read the other mails to the subject.
> In short, the theory is that a "&&" or "||" comprises a
> check for the exit status of the (simple) command left of it,
> and the "-e" only causes an exit if the staus was not checked.
I understand this "logic", but

   2.9.1 Simple Commands
   A "simple command" is a sequence of optional
   variable assignments and redirections, in any sequence, optionally
   followed by words and redirections, terminated by a control
   operator.

That is Simple Command
cannot contains "operators" like &&, || and | etc.
according to that spec. (Words \intersect Operators) = \epsilon

Their official grammar
   %token  WORD
   %token  ASSIGNMENT_WORD
   %token  AND_IF    OR_IF    DSEMI
   %token  DLESS  DGREAT  LESSAND  GREATAND  LESSGREAT  DLESSDASH
   simple_command   : cmd_prefix cmd_word cmd_suffix
   | cmd_prefix cmd_word
   | cmd_prefix
   | cmd_name cmd_suffix
   | cmd_name
   ;
   cmd_name         : WORD                   /* Apply rule 7a */
   ;
   cmd_word         : WORD                   /* Apply rule 7b */
   ;
   cmd_prefix       :            io_redirect
   | cmd_prefix io_redirect
   |            ASSIGNMENT_WORD
   | cmd_prefix ASSIGNMENT_WORD
   ;
   cmd_suffix       :            io_redirect
   | cmd_suffix io_redirect
   |            WORD
   | cmd_suffix WORD
   ;
   io_redirect      :           io_file
   | IO_NUMBER io_file
   |           io_here
   | IO_NUMBER io_here
   ;
   io_file          : '<'       filename
   | LESSAND   filename
   | '>'       filename
   | GREATAND  filename
   | DGREAT    filename
   | LESSGREAT filename
   | CLOBBER   filename
   ;
   filename         : WORD                      /* Apply rule 2 */
   ;
   io_here          : DLESS     here_end
   | DLESSDASH here_end
   ;
   here_end         : WORD                      /* Apply rule 3 */
   ;

So, no AND_IF or OR_IF inside.

"Nonsense" because this behaviour breaks BOTH
"exit if Compound Command fails" logic of 'set -e'
and their own definition of Simple Command.

 >>   true  && false
 >> does NOT exit with NetBSD's /bin/ksh, pdksh, mksh,

> Are you sure?
No. My bad. There were too many checks :)

> This seems to boil down to a documentation issue.
Chaos :(

-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index