Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Robert Elz Newsgroups: gnu.bash.bug Subject: Re: %q with truncating size loses safeness of %q Date: Mon, 20 Apr 2020 04:33:49 +0700 Lines: 35 Approved: bug-bash@gnu.org Message-ID: References: <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> <4bacf2f0-9802-67d3-f30b-80e37d058a4a@case.edu> <22039.1587163072@jinx.noi.kre.to> <29253.1587332029@jinx.noi.kre.to> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1587332071 30891 209.51.188.17 (19 Apr 2020 21:34:31 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: chet.ramey@case.edu Envelope-to: bug-bash@gnu.org In-Reply-To: <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> Received-SPF: permerror client-ip=2001:3c8:9009:181::2; envelope-from=kre@munnari.OZ.AU; helo=munnari.OZ.AU X-detected-operating-system: by eggs1p.gnu.org: Linux 3.x [generic] X-Received-From: 2001:3c8:9009:181::2 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: <29253.1587332029@jinx.noi.kre.to> X-Mailman-Original-References: <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> <4bacf2f0-9802-67d3-f30b-80e37d058a4a@case.edu> <22039.1587163072@jinx.noi.kre.to> Xref: csiph.com gnu.bash.bug:16179 Date: Sun, 19 Apr 2020 15:40:39 -0400 From: Chet Ramey 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 '*').