[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Avoid unportable nested double-quotes and backquotes.
From: |
Paul Eggert |
Subject: |
Re: Avoid unportable nested double-quotes and backquotes. |
Date: |
Mon, 24 May 2010 12:48:11 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 |
On 05/23/2010 04:37 AM, Bruno Haible wrote:
> In summary, I did find a shell that does not understand "`...\"...\"...`"
> but I did not find a shell that does not understand "`..."..."...`". That
> paragraph in autoconf.texi dates back to 2000-05-19 12:17:29. It may have
> referred to shells that were in common use between 1995 and 2000 and have
> disappeared by now.
There is a similar warning in the POSIX-2008 rationale. The rationale
for quoting
<http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_02_03>
says:
Some implementations have allowed the end of the word to terminate the
backquoted command substitution, such as in:
"`echo hello"
This usage is undefined....
I interpret this to mean that:
ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
results in undefined behavior, since a POSIX-conforming implementation
is allowed to interpret this as if it were:
ac_dir_suffix="/`echo `"$ac_dir"|sed 's%^\./%%'``"
which obviously is not wanted.
It could well be that no widely-used shells currently take advantage
of this misfeature of POSIX; still, it's safer to conform to POSIX
when it is easy to do so, as is the case here.