From nobody Wed Jan 29 14:40:01 2025 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 4YjlDf5vWrz5mqlV for ; Wed, 29 Jan 2025 14:40:02 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YjlDf519Yz3M65 for ; Wed, 29 Jan 2025 14:40:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738161602; 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; bh=S8Mf8Nf/EJNPVC342DpwW5du/Qmg27NS87vSIlMaCoY=; b=JrizMQ/MPMe8qWO7yhQTjvI6+ywR9MGrlOO6585ubxkNIpJyJE2uSmzt5kgqhjiK+Vyifw 6t4CuL0zbF66irgn8gJTT94Xrm/zv8/S35iFcoXBX5H0PdFj+oakMovdw43jekMO06aNYe 1qrJrJUX2xvxPCQ8HHOO5hbkA370ZlSLhwRnFpGkukin5nOlP6hflilvjvd+/pdUAWBHrI c9PtKaUuxfItxqrmmv5IZP+92A6vtcN31gdsI/BNpatHERCJMVz9lj/B5/9kytEp2rUd1I JSfGOwgXy3Q9HI2lW4oMgX+Rq06x7+vLPuSIbE3Eflom4411Xx71vathz+8NCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738161602; 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; bh=S8Mf8Nf/EJNPVC342DpwW5du/Qmg27NS87vSIlMaCoY=; b=bHAgwXZS6Ri5ZdQl7jpOS1AK7J74AUpRkG7mOkhoQ7zzvJCUwwZ6JytSkInyIArbIhqr5s 8LusXnd6sjXlL5lBE9TCBhgqQMIVwdsPCOWoky9EGSNPAkVLqI5nKX8lL/pgodFP5/XLtG yWohNxHW1OaBFWWqznEqsJw6Uj+I0K/CwE7Q5Vyzpy/ResgFVsLX0Q0T8vABkoGL++W2gu L8Ksd5WBcqVFOygWnYl9MECvcdQb9nhYBeD7G0r/tbn/yI0nxxGA1AtX5tM0lzl1Wmjnn5 D5rWqajMSSOwKiJoE+s2y3jzLmtfI923IRnl2l3ohDp4W7UboIZv1RTfU0ZDfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738161602; a=rsa-sha256; cv=none; b=UnFMUt+KuOMpteCr5UGZwmx1oWqnNnJ5iC1qSBxXTNvlgV8/sogQhYAwFFKr+/CAHDjSiC yVzM5qib7Z1q7fQXvRqw8KIIiMtRVNh+xAU6X0dviMbT1KuiF70qkTO6Iu4mHHmLVIIaaJ fpZNlX1ZuWO6zan/7VF6hF3pbTqNhUxu2aXbJJZ647a+9pjfRahCrOl7gqrhd3olxidn6x yJKR20IKBSoMv8zVBatXG9/8CDRTFJ45sFpIZ3/DkJbKgfsZwqdqlj+PCDl2c2kNIubkbr L77/TAcADF+qOBp7mb2SPd+BC6WpYsf9d1J7n/Y9dmhFNk97DCoFOJzWWBI4vg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YjlDf4HGjz15CB for ; Wed, 29 Jan 2025 14:40:02 +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 50TEe2hQ068245 for ; Wed, 29 Jan 2025 14:40:02 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 50TEe2Rk068244 for bugs@FreeBSD.org; Wed, 29 Jan 2025 14:40:02 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 284434] ed(1) special replacement with "%" doesn't quite match with man-page Date: Wed, 29 Jan 2025 14:40:01 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: freebsd@tim.thechases.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D284434 Bug ID: 284434 Summary: ed(1) special replacement with "%" doesn't quite match with man-page Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: misc Assignee: bugs@FreeBSD.org Reporter: freebsd@tim.thechases.com From `man ed` > If replacement consists of a single `%', then replacement from the last s= ubstitution is used However, there seems to be a bug in this if the closing delimiter isn't provided. Normally the closing replacement delimiter is optional: s/foo/bar/ s/foo/bar (both replace "foo" with "bar") However using "%" per the man-page seems to require the closing delimiter. To demonstrate $ cat test.txt a b c $ ed test.txt 6 1s/a/hello hello 2/s/b/% % ,n 1 hello 2 % 3 c Q $ ed test.txt 6 1s/a/hello hello 2/s/b/%/ ,n 1 hello 2 hello 3 c Q So the biggest issue is that, without the trailing slash, it replaces with = "%" rather than the last replacement text. As a minor side-note, when using the most recent replacement (with the slash), it doesn't print the resulting li= ne the same way it does with a normal substitution (i.e., note that the first example prints the "%", while the second emits nothing) It looks like src/bin/ed/sub.c:77 has the test if (*ibufp =3D=3D '%' && *(ibufp + 1) =3D=3D delimiter) { which should likely be something like (untested) if (*ibufp =3D=3D '%' && (*(ibufp + 1) =3D=3D delimiter || *(ibufp + 1) = =3D=3D '\0')) { --=20 You are receiving this mail because: You are the assignee for the bug.=