Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Sam Liddicott Newsgroups: gnu.bash.bug Subject: Re: %q with truncating size loses safeness of %q Date: Mon, 20 Apr 2020 08:36:43 +0100 Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <4bacf2f0-9802-67d3-f30b-80e37d058a4a@case.edu> <22039.1587163072@jinx.noi.kre.to> <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1587368248 20563 209.51.188.17 (20 Apr 2020 07:37:28 GMT) X-Complaints-To: action@cs.stanford.edu Cc: Robert Elz , bug-bash@gnu.org To: Chester Ramey Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=liddicott-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rY4mcXuc5Mop95sAWuKYV5QeLAG3efqdMIrpDjxFoh8=; b=ASJ9ne8RRR4kKjNTS2pQ5QBVrpasGgvaGdFGrS/0n2vTB7yoQss5FoBZWzrrnoZAlL Kp0D8RxjajRAAvoiYzk0w+26eZf1A/qpJxyuH8b6bPe7yfhozXxvcclJaemltfLdvHk1 m/P19DGeplKC3PVHBAJErhl2yiONXmDQie5kwyv5qSLPT1HJiDtW4Vz+WdD8WhKzx7Db AT8Hen8ySDkOB5EtXTlecebs6BnLV1V6VIWZxf1YJyZct8r4Lgco2S6JOxeAWuVtKorL oJgWOCsb5IvfHEU7/AVdOSaFz0gCK1vF4iqn/9jhDEpVVVbINvO10SSCFdMIqfYMseY8 0DqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rY4mcXuc5Mop95sAWuKYV5QeLAG3efqdMIrpDjxFoh8=; b=q547PE4WNimA4ZHvuQIbdmuTDEuCOaEOc762N15wChkId/ZzmXu096X2eFRfPX7JEA gazD3TOdPrp6qtLdXLnNG8bFYGt8zk7XTwmrxCxojhHBWz1gkrqUfDBxHRHUWphFNqxL cvlFS1qOZI+/X+B4pk2IahJbchr1kK3fYmu0cXhyFmM16mZSgwuEK7iKp+MbO94CY/yv D2jMUWwL8X+7fv1CCTobrHOKpfSVzPqJNzLxPB1x2r+A8Uy/l/wn3CWwWbE+hrCYbO76 CG4ZLKQmRhDYVOD4euqt+gyY2yDXXwsGBke/xqwOOqyYVHdT4kiyDqFL+kfAEJTrfDM/ ZUeQ== X-Gm-Message-State: AGi0Puaqh5VyzZiGXdjcFIi/Hs+YMRg/1nmAZtdnvjhJmW/ew7D5zP72 KRQLBR2Z0o4IoRrpKew3/tVCBui4OtBUf9Rapexqxz3Apzw= X-Google-Smtp-Source: APiQypI+RrHLnQ8ae9eg48zJBH96GtXZYSw5N4W3emP/erxl86cQdTwjjZCMFZoBPKacCcPXASOLoSsf4iL7dSLHhKQ= X-Received: by 2002:a2e:50b:: with SMTP id 11mr6482327ljf.233.1587368240962; Mon, 20 Apr 2020 00:37:20 -0700 (PDT) In-Reply-To: <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> Received-SPF: none client-ip=2a00:1450:4864:20::243; envelope-from=sam@liddicott.com; helo=mail-lj1-x243.google.com X-detected-operating-system: by eggs1p.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a00:1450:4864:20::243 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: X-Mailman-Original-References: <4bacf2f0-9802-67d3-f30b-80e37d058a4a@case.edu> <22039.1587163072@jinx.noi.kre.to> <8c5bdd2c-bc61-a885-6a05-690ef7f515ce@case.edu> Xref: csiph.com gnu.bash.bug:16183 On Sun, 19 Apr 2020 at 20:40, Chet Ramey wrote: > > On 4/17/20 6:37 PM, Robert Elz wrote: > > > This happens only because of the cheap way we (and I presume you) > > implement things - in any rational scheme, it would take the precision > > chars from the source string, and then quote them. That, or at least refuse to emit a dangling escape char. There are arguments against both. GNU Coreutils printf rejects size specifiers for %q and %b, probably for this reason. > Nobody, including POSIX, is rational, then. Chet, I don't know that POSIX attempt to make a guarantee about output being reusable as shell input at all, so I don't know that we need to fallback on POSIX as a reason to break that guarantee. I that although GNU coreutils printf doesn't exhibit this behaviour of %q (entirely rejecting size specifiers for it) ksh does exhibit this behaviour, I will make a report there. This is another candidate for shellcheck I guess, which reminds me that I forgot to submit the one for leaky named file descriptors (in contrast to numeric ones). Sam