Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15182
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | astian <astian@e-nautia.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: backquote peculiarities |
| Date | Tue, 16 Jul 2019 19:03:00 +0000 |
| Lines | 60 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1526.1563309668.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> <d730380a-b214-560e-9554-4a6adca68b0c@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 1563309668 13558 209.51.188.17 (16 Jul 2019 20:41:08 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | chet.ramey@case.edu, Robert Elz <kre@munnari.OZ.AU> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=simple/simple; d=e-nautia.com; s=e-nautia; t=1563303849; bh=mPxWBgcKUpse5r/FeR3jttpTh9P34jtK2SBPqoXiI8A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=MmfZXieprJf+XtQD98IsmT283Ac0yTsFKbhjhj0e6o+Q3L2lihNcLqVNZoo2NyAgG EysJrDr/vFwwiTtcJ33jYn9JfHrl5aOwpH1pOBzxDtxY7md4jCawDvMWBjgSPacePN 8Pn1NXPdRqRaZko3hfD/49xlFUmY40Ga9PFZYE2I= |
| 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=1563303849; bh=mPxWBgcKUpse5r/FeR3jttpTh9P34jtK2SBPqoXiI8A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=MmfZXieprJf+XtQD98IsmT283Ac0yTsFKbhjhj0e6o+Q3L2lihNcLqVNZoo2NyAgG EysJrDr/vFwwiTtcJ33jYn9JfHrl5aOwpH1pOBzxDtxY7md4jCawDvMWBjgSPacePN 8Pn1NXPdRqRaZko3hfD/49xlFUmY40Ga9PFZYE2I= |
| In-Reply-To | <d727f1de-2a10-983f-2c69-689e3665d1c2@case.edu> |
| Content-Language | en-US |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2001:41d0:303:7741::1 |
| X-Mailman-Approved-At | Tue, 16 Jul 2019 16:41:08 -0400 |
| 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 | <d730380a-b214-560e-9554-4a6adca68b0c@e-nautia.com> |
| 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> <d727f1de-2a10-983f-2c69-689e3665d1c2@case.edu> |
| Xref | csiph.com gnu.bash.bug:15182 |
Show key headers only | View raw
Chet Ramey:
> 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.
Ah, thanks for the clarification. I wonder if the excerpt below (particularly
the last sentence) would be the relevant wording of POSIX, i.e. that some
shells might interpret the command as the concatenation of a double-quoted
string, the unquoted $i, and another double-quoted string:
"`printf %s "$i"`" => CONCAT("`printf %s ", $i, "`")
Which would then lead to "undefined results".
Cheers.
---
2.2.3 Double-Quotes [0]
Enclosing characters in double-quotes ( "" ) shall preserve the literal value
of all characters within the double-quotes, with the exception of the
characters backquote, <dollar-sign>, and <backslash>, as follows:
[...]
`
The backquote shall retain its special meaning introducing the other
form of command substitution (see Command Substitution). [...] Either of
the following cases produces undefined results:
- A single-quoted or double-quoted string that begins, but does not
end, within the "`...`" sequence
- A "`...`" sequence that begins, but does not end, within the same
double-quoted string
[...]
0: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: backquote peculiarities astian <astian@e-nautia.com> - 2019-07-16 19:03 +0000
csiph-web