🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4149

Re: [RFC PATCH] quote: make sq_quote_buf_pretty() prettier

#4149
From: "D. Ben Knoble"
Date: Mon, 30 Nov 2026 17:02
30 lines
12958 bytes
On Mon, Nov 30, 2026 at 11:39 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
> On 30/11/2026 15:19, D. Ben Knoble wrote:
> > On Fri, Nov 27, 2026 at 11:54 AM Phillip Wood <phillip.wood123@gmail.com> wrote:

> >> +               } else if (*q == '}' && brace) {
> >> +                       brace--;
> >
> > I think this simple counter may count wrongly for scenarios like
> > "}{a,b}", but I haven't tried it myself yet. My shells (Zsh and Bash)
> > both do the following:
> >
> >      $ echo }{a,b}
> >      }a }b
> >
> > and I *think* that brace==0 when we see the comma here, even though it
> > would need quoted to avoid expansion.
>
> We only decrement "brace" when we see '}' if "brace > 0". If we see '}'
> when "brace == 0" then we quote everything up to the next backslash
> escape or the end of the string. So we decide to quote this before we
> see the comma.

Doh, I missed the "&& brace"---thanks!

Some other time, I (or anyone interested) should throw a fuzzer at
this and see what happens ;)
Technical Details
Message-ID: <CALnO6CCKMRx8=LS34kadG75Xeh0q6DVO8sEGNO1Mv1ty1HMyXg@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76712-linux-kernel-git=dewy.ru
References: <ee7de58093c69fbbab686a68b5b781bc60d90a2b.1795798429.git.phillip.wood@dunelm.org.uk> <CALnO6CDyTh+O_S6Q6Nq46wckLGXdvTKJmU6uK_SKn5S=p4X20g@mail.gmail.com> <27a384cb-7279-4061-9925-c55107575f6d@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76712-linux-kernel-git=dewy.ru
From: ben.knoble@gmail.com ("D. Ben Knoble")
Newsgroups: linux.kernel.git
Subject: Re: [RFC PATCH] quote: make sq_quote_buf_pretty() prettier
Date: Mon, 30 Nov 2026 12:02:05 -0500
Organization: Usenet Network
Message-ID: <CALnO6CCKMRx8=LS34kadG75Xeh0q6DVO8sEGNO1Mv1ty1HMyXg@mail.gmail.com>
References: <ee7de58093c69fbbab686a68b5b781bc60d90a2b.1795798429.git.phillip.wood@dunelm.org.uk>
 <CALnO6CDyTh+O_S6Q6Nq46wckLGXdvTKJmU6uK_SKn5S=p4X20g@mail.gmail.com> <27a384cb-7279-4061-9925-c55107575f6d@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1477408"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/OkZveHnm93r0CGugR2XS7tBw6Q= sha256:xy2pH8J8m4tjurVQ23t84eugtZNA3F+I5z7irEBTVYE=
	sha1:H9Gi29BktTTwlY9cj6E6mPRV/HQ= sha256:PG3LB4zvIFeNyj6+cltpLRHpnd/Dz1NC9oOiAWbSpZ0=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 331C9125FF7; Mon, 30 Nov 2026 20:02:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id o31ULwI3U2rA;
	Mon, 30 Nov 2026 20:02:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-76712-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id B47BC125FF3; Mon, 30 Nov 2026 20:02:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B62B626E14; Mon, 30 Nov 2026 17:02:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796058140;
	b=S5DLEAsAfa/fMeHqEJjIEzHhlKZGittnzdHpXeGx0W3sTCIc5NcrP23ghyxZp8mPaUXx
	 vyVw0ou/Ub5sXwnB+xOnsl2t9LE/XdqBuwKUxt+8iSovelRc9vcU+wZfDDNvlj/uH/PwA
	 1o3jwfOwfvLowqDEenib8GAja0zGUbNZKXOPhEw7RyjmVqQwyww7UqZ2a7svrqFMKEsvl
	 0d6w5nteGG4T2Ub+hDpMgGa5QFbcFsWpQzLRvrFexm9U+TIhzSzM26iCPlPrynfrwL2NL
	 rk9GPd+g0x8hn+FvbOFcuLJn1qD6Gy4mdtY359jqORvJVLafOJipD7iOGNrkII1DP+g==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796058140;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:References:
	 In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=kFNUdMwazqciRnBv+rz8y4ciGeQBYiYKCYc8rl49zT0=;
	b=3jsi514HIPIyXr164ztV0FmTGkE3KB6FRLHAd47OyD+xaDrHnP8iuriyia9Ezh1tXO94
	 Q51JuTMWuyr6O1Ldg+8gwZNQmBs6WYMTHk3kzhy6yVIXLv6pg2Pna0EO+tbnnJ+ib3L4J
	 07oVgEy6sdh4tCsxrWHGBVAsiAvP46rAVsZAN7aN+YzQavpplkqgE8brsh+BlolBC1CGx
	 69cOEBQyyOviyWqB0ZDd6pfAQgpfJqmpajvmCNh8Q47t8n5p+viRq3qfbNn4xuUBSeZg0
	 2xxQM9PDAD7/h1j7SHHARUv+EFdHR2SNyxwHnomj9bS2CEP543UteVkQU8aDo/d3w2g==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0E6EkCSd;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BEE4606A32C;
	Mon, 30 Nov 2026 17:02:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0E6EkCSd
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.216.47
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796058139;
	b=DOzc052Qr6kuuA7jGk3ntGnQOkihGOfaPsPyhQvWP283amqMKL9zxgx0beKmK7X7/OuV
	 oJ3bXjSANw6aTugNJ1YasMkDEZStpqURWgizNUyrswIcHZALQjU+jErVvzaO08/K+yA0O
	 AxRFRqF2ka3Y6CVc1nHPzjVzmIiWddjOjsSLcjR4ns4V0xkcCSlHu009WKQGCVni6Mcpu
	 eF9x1olMGs0pxWWS0Shwj0AJInNkQrrHkzTyWj344ka7J71EG+tfpretPaXS9SWL2PMSA
	 KMwztZNveap5LsEHnaY917QNFt3xVlFTvOjbJUG8qWNrpAJIR4mZ07BFW/vMzvr2qKw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796058139;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:MIME-Version:References:
	 In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=kFNUdMwazqciRnBv+rz8y4ciGeQBYiYKCYc8rl49zT0=;
	b=hEoH6W6VHQK4wzIHkObvZ56+LZuIJxk1tDnkVKc9hSeLvjMHd5EBevHn1xrt7OX1UDH1
	 4FNeki9nIB/Idc05o+hnEWtDPC51FPRaO6yINmGg/4t2bEv8ehuyB7f9yXXSnAlNZgmSy
	 O/pHhemccPJCLIBlUt2m6Pjdc3VozYwa8s+Jr/9QaLQpXJQWlfagkEWImks84/nCaA4DD
	 gkoYgs+4uLxXR/7g8xdWxiVm0QJGuB52RjeOfu5O67W73wa+BIg5MwsjGIIZW9E9FOveu
	 oiVssbs+Eg2J5c0WAwY5anjeiDTKTA/NOWwop4sMF+1AGSH0MUwuvxvxMMHBSm+ZTbQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0E6EkCSd;
	arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.216.47
X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 507E7606A31C
	for <git@vger.kernel.org>; Mon, 30 Nov 2026 17:02:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 507E7606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3b413997581so7432620a91.2
        for <git@vger.kernel.org>; Mon, 30 Nov 2026 09:02:19 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796058139; cv=none;
        d=google.com; s=arc-20260327;
        b=XRbsyudpbNNyAcaX4V1tiSYNMaBcBPa4BGqM4HUoQgX3k2PfxRlhmuPMSSDH+GUcNU
         J8s0phheSLbnG+Kd6mTa8yT63Cye7y/8AMtOHCbb6xDUS3QQjguKpr5fFh9A9vmsukF5
         3KEpP7b49ZM2MrSTbnt9njvJUkeiMoMX8tR4mUTXxUU3N9pZo+zgsJyJGWTLzUM0iPk0
         zOv44Lx1CrkEAAuxnjtkOcj8WOqKv8r9cW3rNY1rjm9zpsCgD+2fczxYHq1EeW/YE0dA
         3eqhbMZLq5+Lpki0pCRtOrbFiNtLSURZB/rmi5QPbVKNkhTrjOnbf+pG7fjex/pi9VVt
         dj8w==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
        h=content-transfer-encoding:cc:to:subject:message-id:date:from
         :in-reply-to:references:mime-version:dkim-signature;
        bh=kFNUdMwazqciRnBv+rz8y4ciGeQBYiYKCYc8rl49zT0=;
        fh=V15g25dQ0Z8NAYfnKi4FHqeNtPtvnIvT/pVDW497QhI=;
        b=VLY7o3+FOdRg9H3zi/PRjrb48UAc0zpZSytzD6fsTmc//gebOk+7nXKBSNKvfxBDAH
         sUzbhIa93JosSlKOO0WBQoIkXS3Bpz9vWZ6Sphu5thoA+T0cDFrGHWg0HigoF84oif5k
         37goMQGqL5jBZfFgfxOyaHCJcM43wC7dFcYRMbX6uifcc6EqPuTz1zK71srPmO84hSQD
         WEHbg0lg2O2x2UIN7xj1mhpOO/Mwj1hayY2JmP28xAWLx+PG35Z/vaSwm53UmVHQmIxD
         NW6wLn3L/Ujc50D47KdY0aF2xJrACtsq6Nr6uozSwIKUfb2o/YBlVudiFudfylnXIE0G
         LvVg==;
        darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796058139; x=1796662939; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=kFNUdMwazqciRnBv+rz8y4ciGeQBYiYKCYc8rl49zT0=;
        b=0E6EkCSdp/P57v0PH+duDntcF5BGWKRpsW90GGFPPWNh/VlFmM3HOrHs3wk68qi5r4
         DFuAtasxBOeekYpjdXvdcJz1iuz2QRKHVGEBVR9fnGt5Od0V8SPXyd1nh06gqoU0BgQc
         DVrSx2+XAfKDNHXbr0YW6rLcfvzz3fQkmjyLRAAtu88q52Sjwo7aF+pZgSKOyqrmFN+p
         8AZt/LE5cGNlhxqbFvy/f0cWZhOP2zbn6MuEmJMTvh6yyIgT7CN5ywlEqbq/qua0pef5
         DuEFjs1GYE0Oe8wVmhPZl5bXlrEBJfcj3J435Q8BOuWcFL6wCRKkNpQ/R0WAygaUT9z5
         P5JA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796058139; x=1796662939;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=kFNUdMwazqciRnBv+rz8y4ciGeQBYiYKCYc8rl49zT0=;
        b=iencnECN3FiVflcV98KziEWjcwcnVD47V9z6lyNk/2v1MySWmg37cabHzHfq0Pz5ki
         4Q2wmnznkLn5scemfno3+DLS8gNGF3yYnmQxPrVdxqDmG4xv/pY+BPQVIJWEhB1Qbmtk
         UgnLkJAxUvmdpaJ8t18eH/oga39+BPBmOaYW4pZo9yYBL4IhqRPCJ3bh1eCuTn9UhDkm
         wKETTmjVZ4ysOlcZSmyIMjGVWOLFWKJHSTdNN21oSLy5kuiRY2ojgXFhdEQOtSf7dMHr
         Sq6WbN+bi45+8RDouUfTTsNahPpBSWF0sGmt0Xd69FS+mXhsVgHpgQPhUZAc8vLz99Hy
         yTGQ==
X-Gm-Message-State: APuU4Z+nuDwDP8iZ/T9cNMCRgpJnLTvX45yeB8kIhcvbuIvLVjIZPDYW
	wpcp4mHOEg9WUGIjNNjumfV4EjvTPQCIkqBaK+ymPKhWjBPEfX4daOAYFyslMPPdBWKBrL44Dad
	PYG7+qlYDUooYwdg6GEh+3eZBmV/sMoc=
X-Gm-Gg: AZFdTZcG/GrFXY2Q6cOEp1adRfa6FhHBadxD1CAaFkkMVE+/om+LadLkbM0FlZdye/t
	S6mxGMIzqZR9InO+1Y19cNz5i3BxqJGK4RfS9JsI7cUzC6UXHTvuV+QLF31nJiwoWFlf6UEwQCB
	vxXqBIEeKMRRQCSI+Uy8Y15SgfZ+EYtG2dvBgSyUHXh/S6LyZzCfx1WXtWC/1YyzMgat6g5w78Q
	/dWWbAJ2CE29p3ogC9cNrGVnBlhrTCOSIKFfsvde85YS7I3i9J/ujJgRDCIzkE0gnTazmgKhcVe
	k3iqMYtKHcGUCUzkZQaOLvT6rcPvzXXOeTEDtnLMbhd58RRdA4hjBMmPLtQLzY+qB7sl8dz/eQG
	JEOOFgL0/6xE5Q90bQIi1Y1/4AupPF0qMFQdvfnXXx0LUQqK/5x5pI3d5wK2VwMXKX55m9jg12u
	vRBPMFcbOonUehKsloAnFIA2aBC13FRdhopPlQ/fCrYAbJtimY/JxCwDcAMJLVpWN0blYVr7+jr
	U+joTKL6PxEQQ==
X-Received: by 2002:a17:90b:4d86:b0:3ad:4a8b:c6fd with SMTP id
 98e67ed59e1d1-3b41c93b159mr29160351a91.28.1796058137961; Mon, 30 Nov 2026
 09:02:17 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <27a384cb-7279-4061-9925-c55107575f6d@gmail.com>
X-Gm-Features: Aa3M54ptjAHRlZanwmHvIBXmdlVBIMfc0C1Q2WqsWna7TLxWAyqHPivqoMEPO7k
X-Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>, 
	Junio C Hamano <gitster@pobox.com>, MD Nahid Hasan Sagor <nahidhasan141400@gmail.com>