[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quoting in heredocs zsh vs. /bin/sh
Greg Steuck <greg-openbsd-ports@y2004.nest.cx> wrote:
> cat >>conftest.$ac_ext <<_ACEOF
> ... stuff
> printf("(found \"%s\")... ", lua_version());
> ... more stuff
> _ACEOF
>
> executing this fragment with /bin/sh results in:
> printf("(found "%s")... ", lua_version());
>
> executing with /bin/zsh results in:
> printf("(found \"%s\")... ", lua_version());
>
> Is OpenBSD ksh doing the right thing here?
Apparently not. Hmm.
SUSv3 says:
If no characters in [the delimiter] are quoted, all lines of the
here-document shall be expanded for parameter expansion, command
substitution, and arithmetic expansion. In this case, the backslash
in the input behaves as the backslash inside double-quotes (see
Double-Quotes).
>From this I would say that our shell actually does the right thing.
Alas, no other shell agrees. I quickly checked Solaris sh, FreeBSD sh,
ksh88, bash2. They all preserve the backslashes.
> Should the test be fixed or the shell?
Well, in the short term you'll be better off changing the test.
--
Christian "naddy" Weisgerber naddy@mips.inka.de