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


Groups > gnu.bash.bug > #15180

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

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)
Date Tue, 16 Jul 2019 11:16:11 -0400
Lines 33
Approved bug-bash@gnu.org
Message-ID <mailman.1509.1563290210.2688.bug-bash@gnu.org> (permalink)
References <bcd08f6c-1c13-0eb4-92b2-4e904b19a0ce@e-nautia.com> <8091.1563212947@jinx.noi.kre.to> <84005319-e232-8404-fe0b-471dafad381c@e-nautia.com> <d727f1de-2a10-983f-2c69-689e3665d1c2@case.edu>
Reply-To chet.ramey@case.edu
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 1563290211 3544 209.51.188.17 (16 Jul 2019 15:16:51 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu, bug-bash@gnu.org
To astian <astian@e-nautia.com>, Robert Elz <kre@munnari.OZ.AU>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1563290194; bh=t7bAkYxb0B0EJuZAYIiiwoFI1TzObYNGAfYib92kI9w=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=rE+TCqY33K22oPHdBowj9tzG0X3rW83nlXYEIITVfT4E2EhK//SQViuUamkWCm1WdM DV58Yez5g17iC+fiHSW3pSWE9OmbJhu6YtxHxbFvfey7pgHXsOI4irp8Uqv81YJVQVg 6ABeJkvqe+SrJv+6juksby43054oSNGOm6wqnmqLGmFrZNIHutsIU16lW7vNw+YNkBK VbCRQccWwWOLvDPJNx/Bvk/fQyLzTcA+2YUymaQETFxd4woozFZWRTfH44ReExhjCYJ Ee0q90YgeHxgq+mkTs0ig+HAOzrcWFKya3lEzdEoK8nGEhKUOrDg8ioxMyDti+U/Kdq 0yXjtByQ==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1563290192; bh=OnOYSiuVMC5F5N1PVyS3yhtRtdlVbwVUsIpsIiiTiS8=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=9TaAWxMXim5mWWA6++G/YK2kYlkh07ULUYeGEP2lrHh9Pgxkl0ix2Tq8tLYnk/sDxf QOEneW1BwwOvV3qJllowJhnUVMakv5xi43AFfTEVvKIOGuv+G779V6exev17SreP3/+ Hr+5n53/4J9gW9XvtK/rszlr9nVLDw8+vYH9sCCEFdISYfs8IKgxTDY8Tmd4AYLWZ/2 RrIjM7gS/Fr0Fau2+pBrBJEsPmguACV6k9HYPNYmxtftHxMA7qSs8AFThq7W+TjoqU3 +5NchiXoWFHyc7A4/iXPW7lvjX8FLSUiFg1VVyKTaIRhNNC4eV4Ww0zHTVFZy2fGoUL v5m7DQ5A==
Openpgp preference=signencrypt
Autocrypt addr=chet.ramey@case.edu; prefer-encrypt=mutual; keydata= xsDiBEEOsGwRBACFa0A1oa71HSZLWxAx0svXzhOZNQZOzqHmSuGOG92jIpQpr8DpvgRh40Yp AwdcXb8QG1J5yGAKeevNE1zCFaA725vGSdHUyypHouV0xoWwukYO6qlyyX+2BZU+okBUqoWQ koWxiYaCSfzB2Ln7pmdys1fJhcgBKf3VjWCjd2XJTwCgoFJOwyBFJdugjfwjSoRSwDOIMf0D /iQKqlWhIO1LGpMrGX0il0/x4zj0NAcSwAk7LaPZbN4UPjn5pqGEHBlf1+xDDQCkAoZ/VqES GZragl4VqJfxBr29Ag0UDvNbUbXoxQsARdero1M8GiAIRc50hj7HXFoERwenbNDJL86GPLAQ OTGOCa4W2o29nFfFjQrsrrYHzVtyA/9oyKvTeEMJ7NA3VJdWcmn7gOu0FxEmSNhSoV1T4vP2 1Wf7f5niCCRKQLNyUy0wEApQi4tSysdz+AbgAc0b/bHYVzIf2uO2lIEZQNNt+3g2bmXgloWm W5fsm/di50Gm1l1Na63d3RZ00SeFQos6WEwLUHEB0yp6KXluXLLIZitEJM0gQ2hldCBSYW1l eSA8Y2hldC5yYW1leUBjYXNlLmVkdT7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX gAUCRX3FIgIZAQAKCRC7WGnwZOp0q069AKCNDRn+zzN/AHbaynls/Lvq1kH/RQCgkLvF8bDs maUHSxSIPqzlGuKWDxbOwE0EQQ6wbxAEAJCukwDigRDPhAuI+lf+6P64lWanIFOXIndqhvU1 3cDbQ/Wt5LwPzm2QTvd7F+fcHOgZ8KOFScbDpjJaRqwIybMTcIN0B2pBLX/C10W1aY+cUrXZ gXUGVISEMmpaP9v02auToo7XXVEHC+XLO9IU7/xaU98FL69l6/K4xeNSBRM/AAMHA/wNAmRB pcyK0+VggZ5esQaIP/LyolAm2qwcmrd3dZi+g24s7yjV0EUwvRP7xHRDQFgkAo6++QbuecU/ J90lxrVnQwucZmfz9zgWDkT/MpfB/CNRSKLFjhYq2yHmHWT6vEjw9Ry/hF6Pc0oh1a62USdf aKAiim0nVxxQmPmiRvtCmcJJBBgRAgAJBQJBDrBvAhsMAAoJELtYafBk6nSr43AAn2ZZFQg8 Gs/zUzvXMt7evaFqVTzcAJ0cHtKpP1i/4H4R9+OsYeQdxxWxTQ==
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
In-Reply-To <84005319-e232-8404-fe0b-471dafad381c@e-nautia.com>
Content-Language en-US
X-Junkmail-Status score=8/90, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw score=8/90, refid=2.7.2:2019.7.16.143316:17:8.317, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_REFERENCES, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1, __DKIM_ALIGNS_2, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __BODY_NO_MAILTO, __NO_HTML_TAG_RAW, BODY_SIZE_1300_1399, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-Received-From 129.22.103.195
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <d727f1de-2a10-983f-2c69-689e3665d1c2@case.edu>
X-Mailman-Original-References <bcd08f6c-1c13-0eb4-92b2-4e904b19a0ce@e-nautia.com> <8091.1563212947@jinx.noi.kre.to> <84005319-e232-8404-fe0b-471dafad381c@e-nautia.com>
Xref csiph.com gnu.bash.bug:15180

Show key headers only | View raw


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/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web