From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17523 invoked from network); 17 Sep 2023 03:48:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 17 Sep 2023 03:48:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1694922522; b=PHWr1BkQQt3LTmSx40bue0vl7ZXEJL0ajg/qYmU2i8ClTbDOO0BniwT7z15FYYNZ3lIQPgyhBf 8bBHlnSB+Ua3/6erdjHG8ut6171+8oY6+qZkL+IbPzOybK/OYAIJaF7dho984eJ2unPa51UbHV 8gfSEc9OZNw3jFZyAYxBNqYApNTDy8cJOLrOEWllSPPvlkCV4xo2KmKcXecC1N5hH4loXZ2awF Qo23RxmYud0xO9lYytCEfqp+kfBE6KH7+VWc790B78uq41LdDa6kgOf4uqT6sqLj+8Hhx6nDdt jxfp14PbYelDF3tqb82chWamD6rOqzJNyAbC7ICQHfFE5w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f50.google.com) smtp.remote-ip=209.85.167.50; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1694922522; bh=VimyYHoY8FLk7xRKZxsbfKCbYovelEtF3rYPOhtTZy4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Z4zJHG1JwpL1RZewr3AgXD9YzdDUszyv0Y9Spb22ozD+YPId+ne2OCec8OyS9QWE2wpKaX8q7a H1YkzQGsSNcz4I9OcMkJZwGEeXKf2dkN3mCytVGz9xccZvbdbOd5lwcLCCNHpQL/WNwvnEu9Bo XLJC6NuyljQrgPLANonWvpHQ1h/isESi8J//zx0rRy6sLiTZM6hpCb8HAk0oN5ZEpptyskfrI3 QPsYNnJcYRwp9Gddgo6HM+J5srbIfvVmT0KC8G4fmvWSeZNi/p9L7C7kklVtrRvqkUv8zR98OS 6lYz033yL/IbU5E8t29NCc+EoTAQaTdcB7Sf2MtHKe5t2g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HXVv61h9WIzFD25t+w4S+DvyGSrW4v+RdYI4CcYf21w=; b=eOdq4VntSyekmfD1mdDXLl2gh2 dly/6H7DgAYVzN55Fh+ZdXh6vykFsCdlKWIxkAceboL5Ck/LgfY7euh8Ti91QtRrkHQGdlRwhtoCe Hn/+0EeahbyEli+ZBV1cXmoRDIda+wVBrFcD5i3XpaiBdZ6mQc2l7QkVaOFRpF6LcxY5w8iVC102o 3YNW/CSmT/yuawt5Th8BIWfVvzJ91x4k/59TA3v8zKozK4R1B/xR737MdylIjRCqTAQEpZZVedCco Rl/9LAoPYspZD2bD/Z2SQr3qv8EVOK2A60D1O9ei0I0aapxMRKlbtFwoWHjCB02MgpVInZlm9i+zb ittZXLeQ==; Received: by zero.zsh.org with local id 1qhilz-000PC0-Rf; Sun, 17 Sep 2023 03:48:39 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f50.google.com) smtp.remote-ip=209.85.167.50; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-lf1-f50.google.com ([209.85.167.50]:55693) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qhilJ-000Osq-Md; Sun, 17 Sep 2023 03:48:02 +0000 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-50309daf971so669963e87.3 for ; Sat, 16 Sep 2023 20:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1694922476; x=1695527276; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HXVv61h9WIzFD25t+w4S+DvyGSrW4v+RdYI4CcYf21w=; b=KxWslQBevgxHMSf980iq/dytE5ZrpFH2jkedM5r+NE/j/pr5Iy2zOQQ51Q/+tUXBkz 2nFhb6uJnbQSqOyd3HK4ztRLCcvZyqk0MU6zquLAnovH0O28gNo26wy07XnjQDwg5Dcm 2Rhq82zCT4eDiMB/QgGx78n4Qg8XiHggf0aIcbrR5OdVMK85SNoz7jfT1zsv5x4A17wO FJ0Lt8fMDK6FssOQ9xjvHSoN+pQ0KI0duf2nw7h6KuAu0qlLoZsCmzHV6EClTElWghAV DyuZntfSCrmCtgSR48JgO9vYqSLn2Xfdu0qNt9NrV8c8yfp126ZC1XGislNIO16C4gqS rzQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694922476; x=1695527276; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HXVv61h9WIzFD25t+w4S+DvyGSrW4v+RdYI4CcYf21w=; b=Nr+hECJhahD6rMDZjaFDgvoRN4V9LULulLMkRqJjfKEKtE0yN5OTbwy9EiHnJ2Q1xl sxfjz54uRnFHdWf+114P7/cEv9njAoGapaMofuHOxuHui03KJ4QwRfYey+EOVfdRqDrX 76oCtLoH6aZSY9SIvsTiCtWZXpU2D/aJWvxLMRRilH/zEUX0o8IE0dZ9u0mfrIawUtYg EidVdfPotcF75bdMDAMSTPpyufPuGxIAvQBIWitePBfYcLEh1kVfVfJ2SG9h/5shaat0 kdkOwKAabn3JZhRDtkRI/c+k4WlgAB1JLKZ0c2diWVW+mXi67jzkIn5KOxgUAQSugBof N5iw== X-Gm-Message-State: AOJu0YxE5PIzGRcgQr8xqDlRYNVUvB7C5Qlnf7W4mxbMDlS1Mb4iQajn ZtyUDSKx1UaNzxQNYmX2GQYZ9+94qKs+YFmyyaHDeQrixqhKxcTsLw4= X-Google-Smtp-Source: AGHT+IEu+2fDqfC8CrEKGYhFdRR3NRDOKcJt9Md0A8bXoHMVq3qizde5sJ75Fv6rU6a26ZgsnZtRGq27u/MrwTkGewo= X-Received: by 2002:a05:6512:3f1e:b0:500:ac10:1641 with SMTP id y30-20020a0565123f1e00b00500ac101641mr5518924lfa.46.1694922476284; Sat, 16 Sep 2023 20:47:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sat, 16 Sep 2023 20:47:45 -0700 Message-ID: Subject: Re: Help: f (repeat) modifier, and histsubstpattern + :s/l/r/ modifier escaping of [{()}] To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52156 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Thu, Aug 17, 2023 at 4:09=E2=80=AFPM Bart Schaefer wrote: > > Proof of bug / concept of fix. This might eat a lot of heap so > something more detailed is probably needed There doesn't seem to be any better approach without actually invoking pushheap/popheap which is likely overkill for most cases of this, so I'm just going to commit users/29160. Here's a test suite patch to go with it. > diff --git a/Src/subst.c b/Src/subst.c > index 14947ae36..7b866e638 100644 > --- a/Src/subst.c > +++ b/Src/subst.c > @@ -4539,7 +4539,8 @@ modify(char **str, char **ptr, int inbrace) > case 'S': > hsubpatopt =3D (c =3D=3D 'S'); > if (hsubl && hsubr) > - subst(©, hsubl, hsubr, gbal, hsubpatopt); > + subst(©, dupstring(hsubl), dupstring(hsubr), > + gbal, hsubpatopt); > break; > case 'q': > copy =3D quotestring(copy, QT_BACKSLASH_SHOWNULL); > @@ -4627,7 +4628,8 @@ modify(char **str, char **ptr, int inbrace) > case 'S': > hsubpatopt =3D (c =3D=3D 'S'); > if (hsubl && hsubr) > - subst(str, hsubl, hsubr, gbal, hsubpatopt); > + subst(str, dupstring(hsubl), dupstring(hsubr), > + gbal, hsubpatopt); > break; > case 'q': > *str =3D quotestring(*str, QT_BACKSLASH); diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 83f0371a1..363846f5c 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -561,12 +561,14 @@ foo=3D(one.c two.c three.c) print ${foo:s/#%(#b)t(*).c/T${match[1]}.X/} print *(#q:s/#(#b)tmp(*e)/'scrunchy${match[1]}'/) + print ${${:-"left[({})]over"}:fs/(\\{\\}|\\(\\)|\\[\\])//} unsetopt histsubstpattern 0:HIST_SUBST_PATTERN option >TINGcd TINGfile1 TINGfile2 homedir >THUMPcd THUMPfile1 THUMPfile2 >one.c Two.X Three.X >homedir scrunchyfile1 scrunchyfile2 tmpcd +>leftover setopt ignorebraces echo X{a,b}Y