From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 08 15:26:05 2023 Received: (at submit) by debbugs.gnu.org; 8 Oct 2023 19:26:05 +0000 Received: from localhost ([127.0.0.1]:58547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpZPg-0000fO-Ob for submit@debbugs.gnu.org; Sun, 08 Oct 2023 15:26:05 -0400 Received: from lists.gnu.org ([2001:470:142::17]:49788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qpWgu-0000da-IK for submit@debbugs.gnu.org; Sun, 08 Oct 2023 12:31:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qpWgU-0001Hh-Eq for bug-sed@gnu.org; Sun, 08 Oct 2023 12:31:14 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qpWgR-0005vo-O0 for bug-sed@gnu.org; Sun, 08 Oct 2023 12:31:14 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6c61d955161so2135569a34.1 for ; Sun, 08 Oct 2023 09:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696782668; x=1697387468; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=jHiqIb0MrDNNSyFOAOvKp9JKA+O5aE04FDMsTxnzpnk=; b=BGnrAuHTQKEhM5M3387Ph07wel8rh6iuNU3Fsce8LS4LwrOJifulgLTfCHRIx95rL3 pRddOBZ7BMvowC4tM+s8B6J2jed4CyxAaidTv3+ilxCZ0NIi65D8Rl8hdkvhhjhvaEVZ BKvWXxAqEiqhWr/EhqZp/yEEy5fHw+vuq8+ywZLBpGGUp9hNvzVkhbAZce0rwjiO4uhR GNSRvt1rKnIyPn0E+ku5zb4/At2KDK82ARva9SGdfNHRdiCjGDES50vRGF+Fc0fmOAsr sxaf/btW2+unNyPNc/hKo/cpWx6BaUX0SD7HtjpLmL9K73HPi7ZozChbXam36gOd6iLa ndzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696782668; x=1697387468; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jHiqIb0MrDNNSyFOAOvKp9JKA+O5aE04FDMsTxnzpnk=; b=CviLRXyG9e0q4hvCnQeB/vYiT3po4vO1XlapdWE9ZLjOQ8dSolC0Kl4QE5ae7GGEEI VBzO7T/EUm04r4hZiDks9uUtztpSPUB7y12r5NhbAe8aufLRVY4xs5CKXIaBjqgT2XJY 31/8ONydnWqpKmnkTLXvNMr4VEXNiY9tM8ub9BSAZszM3EpKqDWNsD9OMkXtbSsYDjNy ZdQ5OqVhL//5dwu6tDCdU3ASJKRv6avqhqFujrfDUS9ozEU09T1UP9XpYnHwQ/mMYpZk Wphb2dbfzywt4HuS20xLpKrnJ0nAZ9nSd8w5F74+zXv3YDtsCdt9l+nOgC3i5N2Osap7 218w== X-Gm-Message-State: AOJu0YzOJNw6SnqD4K+wnuODBJp8SpLP2/QiWkVZYquwPpkTfTcTQ/rQ NiSq5Sv0Q2Lv5kw+J7sFePZ3Essr6fqt7hblXJ5YxDeCSVM= X-Google-Smtp-Source: AGHT+IHDBqxHPpSnpJnJcWriDAYNuF/L98bw15iZRBR5UoeFOVCMxcEtddOl5pyHQaFF+quzjBnyB7Wm9Ib/jnxK2uI= X-Received: by 2002:a05:6830:c5:b0:6b9:62f5:ac62 with SMTP id x5-20020a05683000c500b006b962f5ac62mr11174747oto.35.1696782668528; Sun, 08 Oct 2023 09:31:08 -0700 (PDT) MIME-Version: 1.0 From: Zachary Santer Date: Sun, 8 Oct 2023 12:30:57 -0400 Message-ID: Subject: sed --debug option prints the contents of the hold space after running the 'g' command To: bug-sed@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=zsanter@gmail.com; helo=mail-ot1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 08 Oct 2023 15:25:59 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) The 'g' command "[r]eplace[s] the contents of the pattern space with the contents of the hold space." Outputting the contents of the hold space then gives you the contents of the pattern space, but it still doesn't make a lot of sense to do. It's not the hold space that was updated. It's the pattern space. $ seq 3 | sed --binary --regexp-extended --debug --expression='x; g; h' SED PROGRAM: x g h INPUT: 'STDIN' line 1 PATTERN: 1 COMMAND: x PATTERN: HOLD: 1 COMMAND: g HOLD: 1 COMMAND: h HOLD: 1 END-OF-CYCLE: 1 INPUT: 'STDIN' line 2 PATTERN: 2 COMMAND: x PATTERN: 1 HOLD: 2 COMMAND: g HOLD: 2 COMMAND: h HOLD: 2 END-OF-CYCLE: 2 INPUT: 'STDIN' line 3 PATTERN: 3 COMMAND: x PATTERN: 2 HOLD: 3 COMMAND: g HOLD: 3 COMMAND: h HOLD: 3 END-OF-CYCLE: 3 'x' updates both pattern and hold spaces, and you get the contents of both in the debugging output. 'h' updates the hold space, and you get the contents of the hold space in the debugging output. 'g' updates the pattern space, and you get the contents of the hold space in the debugging output. $ sed --version sed (GNU sed) 4.9 [...] $ pacman --query sed sed 4.9-1 Being run in MSYS2 MINGW64 terminal on Windows 10. Thanks, Zack From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 14 08:04:55 2023 Received: (at submit) by debbugs.gnu.org; 14 Oct 2023 12:04:55 +0000 Received: from localhost ([127.0.0.1]:48047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrdO2-00032e-RT for submit@debbugs.gnu.org; Sat, 14 Oct 2023 08:04:55 -0400 Received: from lists.gnu.org ([2001:470:142::17]:46062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrdO0-00032M-GE for submit@debbugs.gnu.org; Sat, 14 Oct 2023 08:04:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrdNS-0005ru-Nb for bug-sed@gnu.org; Sat, 14 Oct 2023 08:04:18 -0400 Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrdNQ-0001Ut-0g for bug-sed@gnu.org; Sat, 14 Oct 2023 08:04:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1697285053; x=1697889853; i=dave_br@gmx.com; bh=N21hGSmGf3qVrhn372hO4Rtw336C0WXDQi74UVYkk2s=; h=X-UI-Sender-Class:Date:From:To:Subject:In-Reply-To:References; b=hp2rtyTEye22148ht1FX/KYp5Ol6eZs1nniEZ5c1haari9mw46LAkvOh4TT3zLzTBhgijFLZmI9 4p8mnt5DG/q+5hlyBh1mi4JHf8UAoL760oNRFpVimkNsM6g7PI9EYuBLQyczxpkp85DNlYRt5PCIg sdfJBL2urBtXcAT1Lpr33MBDAjRx5PKwlnG424UK40Zt5JmdHHnIFumjzkMff9IBSbjlrz/udWjaV efgGBaiPGAYvNRlbdb7sA5HXmx+MO/gaKp5XCgw3rTaBp5WdELM4lZCHSNrMaxheqFLFTJ/9Rv2PK qxn4HeDSRLLEOa/OKc5Xz+nBShEZ/GKGAzlA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from swedishchef ([79.33.19.43]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MPXhK-1rDAOk3sVG-00MbeG for ; Sat, 14 Oct 2023 14:04:13 +0200 Date: Sat, 14 Oct 2023 14:04:11 +0200 From: Davide Brini To: bug-sed@gnu.org Subject: Re: bug#66411: sed --debug option prints the contents of the hold space after running the 'g' command Message-ID: <20231014140411.5b87f8ab@swedishchef> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/vEk8GMv4k1OY4y+pA66nbeb" X-Provags-ID: V03:K1:oI6jYwKoLscux0xXbZQhpvBIAs5OaB+W3VSxfakr3ZWI7ZRvj5u zCgQGtGSdiCfSFK4DuIseWKinYV96uMM1Mnbvpgr3UgucHDpzs67U75MN62Z/7q+QGs/85S JctIz96QmMmCHZDpC/fEQWowz3RT0k04Wh/QjHAaLiKpZZUF7Fq630jRmkaiA8ydQJ97X+R sIfIEBrBrEl7t1MM640Yw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:T5Y3EOomZM0=;swQmDiImNq4YVPsFrmMLJyh5tIf jBVuWuSd8Huy9HgxsQH4/0FwwvHAPAxHLI7NYuCJVysatbd4qqnTkkNf2YBRrCN07vDNYvAFo 1HSeGR2PZwSCdH5XgiebRtEwexvxGgWvH9kf0diRUjtExUHZ6ePir9POge4IBjoPhCoR1o7F5 8jw7zOIxe9t58fMdoSA7zR6u2CWJCNWYj2irSzbLjMN3Mng64SnZruAn1PJKpgQskOcQblgMf PlA9wrl8K7ARu/aGjCU7utgPyeuZ21FQdnBTA0mz+FNHettoKWykuBt65BI5qR0CN0PRii0M2 R90rvDdikHJFeBmRG4Mq4EYncBP8A9jpd7nYdNA8Q3aY9KWjZtXqwhJjcbAE37oqkD54uoBoW eo4SEd2CJTOb15jl9XBllOyjd4hAU/ZoXzsztKeB/8VouhwEBT447eXbsFejB4OF07fy0B017 /MCLiHXJnuOcZBwGEWh179VLfL/paEKsrryJlR869I1SkPfJF6G/r9930pgA19s1dwO5EsYtw hBuDvI8p1djzFNpq2n9YZG8uV6UsDEOm/mpBETRcvF+khRmhwzsXOfNe4lnDLWZ/jbFTLve8c rAg6EGcFddGtkH9aG19C5c0UTFgdwDCuipEhtV4bx3jNl6LEx8CuvCmmN3srA8PC5jr4NFX+T loLTqBk0tofSSlMuj5/6/G8Ttt8adCRa/xgrgIfDxNKl590UCbcJ5RFOCOKGvzBFBOgYgXtkb eL/DweikKJKhHAFuGU9Jsxg4ILW6FOEj/ulNr1h1MLQgaJqOknwEckx3lRP8ofqmyGAifJ7pD FNXqWgagp3kAP2m5nkchMviRGJxRnGFrVc+sku2xnL54T1rzniGsTFa3VKy5WgJ1Ip83reftq bAxNLTvtRaFYoEs9lcNy8Y8fn9n/V4mUh4QnY+e0pN5SwqKu35lRk21RL979riFCT87/u0CM+ o8C12Q== Received-SPF: pass client-ip=212.227.17.20; envelope-from=dave_br@gmx.com; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --MP_/vEk8GMv4k1OY4y+pA66nbeb Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sun, 8 Oct 2023 12:30:57 -0400, Zachary Santer wrot= e: > 'x' updates both pattern and hold spaces, and you get the contents of > both in the debugging output. 'h' updates the hold space, and you get > the contents of the hold space in the debugging output. 'g' updates > the pattern space, and you get the contents of the hold space in the > debugging output. While personally for clearness I'd just always print both pattern and hold space after every command, I think the attached patch would do what you wa= nt (which seems more logical to me too). =2D- D. --MP_/vEk8GMv4k1OY4y+pA66nbeb Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=debug_pattern.patch diff --git a/sed/execute.c b/sed/execute.c index 5f82e87..9a43a95 100644 =2D-- a/sed/execute.c +++ b/sed/execute.c @@ -1416,7 +1416,7 @@ execute_program (struct vector *vec, struct input *i= nput) We keep it true because it's what sed <=3D 4.1.5 did. *= / line_copy (&hold, &line, true); if (debug) - debug_print_line (&hold); + debug_print_line (&line); break; case 'G': --MP_/vEk8GMv4k1OY4y+pA66nbeb--