Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15180 > unrolled thread

Re: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)

Started byChet Ramey <chet.ramey@case.edu>
First post2019-07-16 11:16 -0400
Last post2019-07-16 11:16 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow) Chet Ramey <chet.ramey@case.edu> - 2019-07-16 11:16 -0400

#15180 — Re: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)

FromChet Ramey <chet.ramey@case.edu>
Date2019-07-16 11:16 -0400
SubjectRe: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)
Message-ID<mailman.1509.1563290210.2688.bug-bash@gnu.org>
On 7/15/19 6:19 PM, astian wrote:

>> I doubt it makes any difference to the timing, which I think
>> Chet has already answered, but it is worth pointing out that these
>> two commands ...
>>
>> 			printf '%s\n' "`printf %s "$i"`"
>> 			printf '%s\n' "$(printf %s "$i")"
>>
>> which (I believe)) are supposed to be the same thing, using the
>> different (ancient, and modern) forms of command substitution aren't
>> actually the same.   In the first $i is unquoted, in the second it is
>> quoted.   Here, since its value is just a number and IFS isn't being
>> fiddled, there is not likely to be any effect, but if you really
>> want to make those two the same, the first needs to be written as
>>
>> 			printf '%s\n' "`printf %s \"$i\"`"
>>
>> Such are the joys of `` command substitutions (just avoid them).
>>
>> kre
> 
> Dear Robert Elz, I'm aware of several of its peculiarities and I typically do
> avoid them.  However, is it true that $i is unquoted in the first case?

POSIX makes it undefined behavior, and different shells do it differently.
Bash makes the $i quoted within the `` string, as you discovered.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web