From nobody Sun Jun 18 22:59:22 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QkpHZ3zW6z4fPWg for ; Sun, 18 Jun 2023 22:59:22 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QkpHZ2swnz3nWD for ; Sun, 18 Jun 2023 22:59:22 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687129162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PRSNA4GsYkwl/oGYlQNnV7Clv8QWBMm5wm2wW89kFjo=; b=pcmWGtfprNSl1C0fIt45pOfj18I3tSwRmiEnGW0xsasOEHZsgR/+o1yH2jTfhanJFhqWl+ Q/EYJuTEyOOZUXQHJQHiN5hgzPZmxUk/f9KxEzPqv6cKkBG+BXQu2FHy5Y/fmI1c6cr8Ej LNG/diE+o3vqCK6xpQuVFROHJ8l1m5p4TqBTzcDuldMdQIeb41miYa3hFRMrI36LfgH4pu XuHizjIZdsGwYT+bWmzBONxqvKuBIUHAb/lHlhxL1lnBFJc3RzSuBKEOlWzqyprS1hiw5l hdNwfCSDZ3nqnUDyaS6/5tUcRcp2yIj/nCxs6luCEi9DgtFHV077BV4CFSUfrQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687129162; a=rsa-sha256; cv=none; b=xkxeiYczlcbQQ14vLTUuDQdhiObPjc/Cv4O3rOQ3bOa68M0ddjOy7l710j+xq4rPkZYGJl xxXPdLLy/B9en9bH1pBbwQ5aqgd8gHGMMu4vmC85KIocM9AxC2WKCzxG20eHH8FLI5Ghxx 5vPVc2mD/YgeNjUBQ7IaWg28yf21tZvmraat4arBD9qBNvkvHvIOmi/IMxyJS3I+R2TJIf k4Fhl76JZIcoBVG+JkHnzNMtPoUhrHuIxnv3M/AYsMq+SRXmW6XOZLMTHqkVOB8N+CpJ8w eKlvOcmT0OXsgBLTiFw6NJU7nWy1HE09e4vNaRocE9Sciw0QB9ZPA89AjotYLw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QkpHZ1szHztB3 for ; Sun, 18 Jun 2023 22:59:22 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 35IMxMOA005984 for ; Sun, 18 Jun 2023 22:59:22 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 35IMxMHa005983 for bugs@FreeBSD.org; Sun, 18 Jun 2023 22:59:22 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 271817] sed: range change with N results in no output Date: Sun, 18 Jun 2023 22:59:22 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: andrew@tao11.riddles.org.uk X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271817 --- Comment #5 from Andrew "RhodiumToad" Gierth --- (In reply to Mohamed Akram from comment #4) This is the sequence of events according to the spec, as I read it: 1. Read line "a" into the pattern space. 2. Execute the first command: /a/ matches, so we begin an addressed range "c" deletes the pattern space (but does not emit anything and does not start the next cycle) 3. Execute the second command: $ does not match ! inverts the match N is executed, which appends "\nb" to the (deleted) pattern space 4. By my reading of the spec, the "\nb" should be output at this point. For whatever reason, BSD sed does not do that. 5. The pattern space is deleted (as this is the end of the cycle) 6. Read line "c" into the pattern space. 7. Execute the first command: /b/ does not match, so we are still in an addressed range "c" deletes the pattern space (but does not emit anything and does not start the next cycle) 8. Execute the second command: $ does not match ! inverts the match N is executed, which appends "\nd" to the (deleted) pattern space 9. as 4. 10. The pattern space is deleted (as this is the end of the cycle) 11. read line "e" into the pattern space. 12. Execute the first command: /b/ does not match, so we are still in an addressed range "c" deletes the pattern space (but does not emit anything and does not start the next cycle) 13. Execute the second command: $ does not match ! inverts the match N is executed, which appends "\nf" to the (deleted) pattern space 14. as 4. 15. The pattern space is deleted (as this is the end of the cycle). 16. There are no more lines so the process ends. Note that neither the last line of input, nor any line containing /b/, was never processed by the "c" command, so it never has a chance to emit the replacement text. You seem to be hung up on /a/,/b/ representing some block of input lines. T= his is NOT WHAT IT MEANS; it means "start a range when you see a _pattern space_ matching /a/, and end it when you see a pattern space matching /b/". By usi= ng N to process some input lines, you prevent them from being seen in the pattern space at the start of the script, which affects how the first command determines its range. Alternatively, you (or GNU sed) may be assuming that "c" starts a new cycle (rather than executing the rest of the script) for every row of a 2-address range, not just the last one. This isn't what the spec actually says (as you quoted yourself), though it might be considered to be more useful or consistent. (I looked for applicable defect reports against the spec, didn't find any.) --=20 You are receiving this mail because: You are the assignee for the bug.=