[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Avoid unportable nested double-quotes and backquotes.
From: |
Ralf Wildenhues |
Subject: |
Re: Avoid unportable nested double-quotes and backquotes. |
Date: |
Wed, 23 Jun 2010 19:57:01 +0200 |
User-agent: |
Mutt/1.5.20 (2010-04-22) |
* Eric Blake wrote on Wed, Jun 23, 2010 at 02:56:24PM CEST:
> On 06/22/2010 10:04 PM, Ralf Wildenhues wrote:
> > What is ksh's bigger problem with "`...\"...\"...`"? Your previous
> > emails in this thread don't seem to describe it, so far I've been
> > of the opinion that, were it not for pdksh, this expression would be
> > portable.
>
> Furthermore, "`...\"...\"...`" is specified by POSIX. Were it not for
> pdksh, that would be the only compliant way to write it.
> > My patch adds an example for ksh's issue with "`..."..."...`",
>
> Remember that POSIX says that "`..."..."...`" is unspecified - maybe we
> should add a sentence to that effect.
>
> > the pdksh
> > reference was to avoid repeating an example for its issue with
> > "`...\"...\"...`" here.
>
> I agree that it's nice to have only one mention of the bug, and the
> other location link to it. But maybe it would be better to move things
> in the other direction, and have the pdksh section link to the ``
> section, so that all the pitfalls of `` are contained in one section.
All good suggestions, thanks. Proposed update. OK?
Thanks,
Ralf
Further improve docs about nested double-quotes and backquotes.
* doc/autoconf.texi (Shellology): Remove anchor for pdksh.
Move quoting bug example to ...
(Shell Substitutions): ... here. Document which behavior is
specified by Posix.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 81b0845..34ae872 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -14639,7 +14639,6 @@ Shellology
@item Pdksh
@prindex @samp{pdksh}
address@hidden
A public-domain clone of the Korn shell called @command{pdksh} is widely
available: it has most of the @samp{ksh88} features along with a few of
its own. It usually sets @code{KSH_VERSION}, except if invoked as
@@ -14647,20 +14646,7 @@ Shellology
Posix compatibility by running @samp{set -o posix}. Unfortunately, with
@command{pdksh} 5.2.14 (the latest stable version as of January 2007)
Posix mode is buggy and causes @command{pdksh} to depart from Posix in
-at least one respect:
-
address@hidden
-$ @kbd{echo "`echo \"hello\"`"}
-hello
-$ @kbd{set -o posix}
-$ @kbd{echo "`echo \"hello\"`"}
-"hello"
address@hidden example
-
-The last line of output contains spurious quotes. This is yet another
-reason why portable shell code should not contain
address@hidden"address@hidden"@dots{}\"@dots{}`"} constructs (@pxref{Shell
-Substitutions}).
+at least one respect, see @ref{Shell Substitutions}.
@item Zsh
@cindex Zsh
@@ -15163,9 +15149,22 @@ Shell Substitutions
@end example
@noindent
-Worse yet, not all shells understand @code{"address@hidden"@dots{}\"@dots{}`"}
-the same way (@pxref{pdksh}). There is just no portable way to use
double-quoted
-strings inside double-quoted back-quoted expressions (pfew!).
+Posix does not specify behavior for this sequence. On the other hand,
+behavior for @code{"address@hidden"@dots{}\"@dots{}`"} is specified by Posix,
+but in practice, not all shells understand it the same way: pdksh 5.2.14
+prints spurious quotes when in Posix mode:
+
address@hidden
+$ @kbd{echo "`echo \"hello\"`"}
+hello
+$ @kbd{set -o posix}
+$ @kbd{echo "`echo \"hello\"`"}
+"hello"
address@hidden example
+
address@hidden
+There is just no portable way to use double-quoted strings inside
+double-quoted back-quoted expressions (pfew!).
@table @code
@item $@@