Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16179
| From | Robert Elz <kre@munnari.OZ.AU> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: %q with truncating size loses safeness of %q |
| Date | 2020-04-20 04:33 +0700 |
| Message-ID | <mailman.733.1587332071.3066.bug-bash@gnu.org> (permalink) |
| References | <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> <4bacf2f0-9802-67d3-f30b-80e37d058a4a@case.edu> <CAOj-5WCqxqh=Gcda9k6y4orQaQYXPgsOgNEOVN1AdZQrkCVbtg@mail.gmail.com> <22039.1587163072@jinx.noi.kre.to> <29253.1587332029@jinx.noi.kre.to> |
Date: Sun, 19 Apr 2020 15:40:39 -0400
From: Chet Ramey <chet.ramey@case.edu>
Message-ID: <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu>
| Nobody, including POSIX, is rational, then.
There is no %q in POSIX printf currently, so the issue
does not arise there, and in any case, its objective is
not to be rational, but to document what works - and in
the existing implementations of printf %q (or the ones I
have seen) giving a precision for %q conversions doesn't
work in a rational way.
Sanely,
printf %W.Pq arg
would be processed as
printf %Ws $( quote $( printf %.Ps arg ) )
rather than as
printf %W.Ps $( quote $( printf %s arg ) )
which is what we all do (the NetBSD printf doesn't have %q - I have
it implemented, but refuse to commit it because this is just so ugly,
and I'm much too lazy to do it properly).
kre
ps: in the above, supply shell quoting as needed - I omitted it to
avoid quoting confusion... and "W' and "P" stand for the (optional)
width and precision values (numbers, or '*').
Back to gnu.bash.bug | Previous | Next | Find similar
Re: %q with truncating size loses safeness of %q Robert Elz <kre@munnari.OZ.AU> - 2020-04-20 04:33 +0700
csiph-web