Email List: Xaustin-group-lX
[All Lists]

Re: compound commands with subshells/braces

To: Geoff Clare <gwc@xxxxxxxxxxxxx>
Subject: Re: compound commands with subshells/braces
From: Eric Blake <ebb9@xxxxxxx>
Date: Wed, 27 May 2009 05:36:41 -0600
Cc: austin-group-l@xxxxxxxxxxxxx
References: <4A15E71C.3070202@sonic.net> <200905261440.n4QEep5H018582@penguin.research.att.com> <20090527095232.GA18259@squonk.masqnet>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Geoff Clare on 5/27/2009 3:52 AM:
>     complete_command : list non_empty_separator
>                      | list END_OF_INPUT
>                      ;
> 
> (with an explanation somewhere of what END_OF_INPUT means: either
> end of file, the end of a -c option-argument, the end of the text
> inside $(...) or `...`, or the end of the arguments to an eval
> command).

Traditional shells also treated end of file as a valid here-doc
terminator, so that part of the grammar would also need some touch-ups to
make it clear whether this is well-defined or a syntax error:

sh -c 'cat <<EOF
hi'

Also, you need to make sure the definition of the END_OF_INPUT avoids
creating ambiguous situations with $() substitutions interacting with
here-docs.  It would be worth having the standard specify whether both of
these examples are well-behaved (and print hi) or syntax errors:

echo $(
cat <<\)
hi
)
)

echo $(
cat <<EOF
hi
EOF)

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkodJckACgkQ84KuGfSFAYDJyQCfTW56fHmRy6Q5B2HLMnhv7jSC
BYMAoI+HlmcE+sxOjRa4frYDkbT4tnfP
=6fRK
-----END PGP SIGNATURE-----

<Prev in Thread] Current Thread [Next in Thread>