On Jul 16 2019, Ilkka Virta <[email protected]> wrote:
> On 15.7. 20:49, Robert Elz wrote:
>
>> printf '%s\n' "`printf %s "$i"`"
>> printf '%s\n' "$(printf %s "$i")"
>>
>> aren't actually the same. In the first $i is unquoted, in the second it is
>> quoted.
>
> Huh, really? It looks to me like the first one treats $i as quoted too:
>
> $ touch file.txt; i='123 *'
> $ printf '%s\n' "`printf :%s: "$i"`"
> :123 *:
It is not portable, see the autoconf manual:
... is not portable, since not all shells properly understand
`"`..."..."...`"', for example Solaris 10 ksh:
$ foo="`echo " bar" | sed 's, ,,'`"
ksh: : cannot execute
ksh: bar | sed 's, ,,': cannot execute
Posix does not specify behavior for this sequence.
Andreas.
--
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."