Subject: Re: ksh vs sh quoting
To: None <current-users@NetBSD.org>
From: Alan Barrett <email@example.com>
Date: 07/28/2004 11:10:16
On Tue, 27 Jul 2004, Patrick Welche wrote:
> All explained in TFM.. ksh(1)
> The following is a list of things that are affected by the
> state of the posix option:
> o \" inside double quoted `..` command substitutions:
> in posix mode, the \" is interpreted when the command
> is interpreted; in non-posix mode, the backslash is
> stripped before the command substitution is interpreted.
> For example, echo "`echo \"hi\"`" produces `"hi"' in
> posix mode, `hi' in non-posix mode. To avoid problems,
> use the $(...) form of command substitution.
> So it seems sh does the non-posix mode, and ksh by default does the
> posix mode.. Sure enough set +o posix fixed things for me..
Backtick command substitution has always been difficult to get right in
complex cases. If I understand the above description correctly, then
non-posix mode is the traditional behaviour, and posix mode is some new
I recommend that you avoid `...` command substitution, except perhaps in
simple cases. In this case, I recommend changing from
output_cmd="`echo \"X$output_cmd\" | $Xsed -e \"$no_glob_subst\"`"
output_cmd="$(echo "X$output_cmd" | $Xsed -e "$no_glob_subst")"
--apb (Alan Barrett)