A Bourne shell irritation
I was bitten by this today, so I am going to grump about it. Today's irritation with the Bourne shell is that the following is illegal syntax:
echo hi &;
This probably looks peculiar and silly, so let me give a real example that is also illegal:
for i in *watch; do nohup ./$i >/dev/null 2>&1 </dev/null &; done
So is '; ;
', and for the same reason: in the Bourne shell, you can't
have empty 'simple commands', and both '&
' and ';
' are command
terminators.
(The status of newline is somewhat confusing; the best explanation may
be the original V7 sh
manpage, which calls it an optional command
delimiter. It cannot be a simple command terminator, because that would
mean multiple blank lines would be a syntax error.)
This becomes more irritating when you write command lines with multiple backgroundings in them, for example:
foo & bar & baz & wait
Speaking for myself, that makes my eyes bleed. I find it much more readable and easier to write:
foo &; bar &; baz &; wait
(I think a lot of the eye-bleeding is that 'a & b
' is very similar
to the much more common 'a && b
', yet does something radically
different.)
I have no idea why Bourne decided to be so nit-picky about this aspect of the shell's grammar, but I suspect it mirrors some bit of Algol.
(As an aside, I note that the original V7 Bourne shell manpage is a marvel of packing a great deal of information into not much space and being reasonably lucid in the process.)
Comments on this page:
|
|