-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to [EMAIL PROTECTED] on 10/28/2006 10:19 PM:
>> That's because `` and $() have different syntax, as required by POSIX.
>> You should just do $(basename "$f1"), rather than $(basename \"$f1\").
>>
> 
> That's crazy!
> 
> You have nested double quotes which don't need escaping?!

Correct.  Go read the POSIX spec:
http://www.opengroup.org/onlinepubs/009695399/idx/shell.html

In particular,
"With the $( command) form, all characters following the open parenthesis
to the matching closing parenthesis constitute the command. Any valid
shell script can be used for command, except a script consisting solely of
redirections which produces unspecified results."

$() was invented because it is much easier to write normal shell scripts,
without worrying about the extra escapes that are required by ``.

> 
> Let me think aloud:
> 
>     The first thing one encounters left-to-right is a double-quote.
>     So, logic says that the quoted string is terminated by matching
>     double-quote.

No, when encountering ", one follows certain rules while looking for the
closing quote, and one of those rules is:
"The input characters within the quoted string that are also enclosed
between "$(" and the matching ')' shall not be affected by the
double-quotes, but rather shall define that command whose output replaces
the "$(...)" when the word is expanded. The tokenizing rules in Token
Recognition , not including the alias substitutions in Alias Substitution
, shall be applied recursively to find the matching ')'."

> Looks like POSIX and commonsense are two different things.

Like it or not, POSIX standardized the original bourne shell `` behavior,
as well as the ksh $() behavior, and the two behaviors are different.  Get
used to it.

- --
Life is short - so eat dessert first!

Eric Blake             [EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFRDRJ84KuGfSFAYARAmTtAKCcjQBFCmg9mbLbCaiSM7FESgYiogCgtot8
+OwN8s0+jojCpvrcrugWiHw=
=KOED
-----END PGP SIGNATURE-----


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to