Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: astian Newsgroups: gnu.bash.bug Subject: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow) Date: Mon, 15 Jul 2019 22:19:00 +0000 Lines: 49 Approved: bug-bash@gnu.org Message-ID: References: <8091.1563212947@jinx.noi.kre.to> <84005319-e232-8404-fe0b-471dafad381c@e-nautia.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1563229199 3726 209.51.188.17 (15 Jul 2019 22:19:59 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Robert Elz Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=e-nautia.com; s=e-nautia; t=1563229191; bh=zRrCggWChul8hAgf0+vji44zEPxfnzKJPdE7sFTgqtE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=uUvTOOOk8+PK8K+fcEhIYX07w2uGkT/ArHOftgM4j87evGQC73JsMDrWNrGVuU7ZM OHLhoxYfmX5zkWKnrHU9kSh1OWmnAKGfZeq80PFt1Wxn3wAdYTZTXnq/i42s2J53/v GbD1PiH7eaRr0yPNumW+jjgjJukLZynd+jw52oqU= Authentication-Results: m1; dmarc=fail (p=none dis=none) header.from=e-nautia.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=e-nautia.com; s=e-nautia; t=1563229191; bh=zRrCggWChul8hAgf0+vji44zEPxfnzKJPdE7sFTgqtE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=uUvTOOOk8+PK8K+fcEhIYX07w2uGkT/ArHOftgM4j87evGQC73JsMDrWNrGVuU7ZM OHLhoxYfmX5zkWKnrHU9kSh1OWmnAKGfZeq80PFt1Wxn3wAdYTZTXnq/i42s2J53/v GbD1PiH7eaRr0yPNumW+jjgjJukLZynd+jw52oqU= In-Reply-To: <8091.1563212947@jinx.noi.kre.to> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 51.68.35.65 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <84005319-e232-8404-fe0b-471dafad381c@e-nautia.com> X-Mailman-Original-References: <8091.1563212947@jinx.noi.kre.to> Xref: csiph.com gnu.bash.bug:15174 Robert Elz: > Date: Wed, 10 Jul 2019 17:21:00 +0000 > From: astian > Message-ID: > > 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? Consider: i='foo bar' set -x printf '%s\n' "`printf '<%s>' "$i"`" printf '%s\n' "`printf '<%s>' \"$i\"`" printf '%s\n' "`printf '<%s>' $i`" Which outputs: ++ printf '<%s>' 'foo bar' + printf '%s\n' '' ++ printf '<%s>' 'foo bar' + printf '%s\n' '' ++ printf '<%s>' foo bar + printf '%s\n' '' Cheers.