From unknown Wed Sep 24 03:17:58 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#54614 <54614@debbugs.gnu.org> To: bug#54614 <54614@debbugs.gnu.org> Subject: Status: GNU Sed 's/.../\n/' disagreement with POSIX Reply-To: bug#54614 <54614@debbugs.gnu.org> Date: Wed, 24 Sep 2025 10:17:58 +0000 retitle 54614 GNU Sed 's/.../\n/' disagreement with POSIX reassign 54614 sed submitter 54614 Paul Eggert severity 54614 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 13:20:49 2022 Received: (at submit) by debbugs.gnu.org; 28 Mar 2022 17:20:49 +0000 Received: from localhost ([127.0.0.1]:59109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYt2v-0007oU-6s for submit@debbugs.gnu.org; Mon, 28 Mar 2022 13:20:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:33530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYt2t-0007oL-PQ for submit@debbugs.gnu.org; Mon, 28 Mar 2022 13:20:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYt2t-0006Y2-Jm for bug-sed@gnu.org; Mon, 28 Mar 2022 13:20:47 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYt2r-0002n6-QW for bug-sed@gnu.org; Mon, 28 Mar 2022 13:20:47 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B6D09160097 for ; Mon, 28 Mar 2022 10:20:42 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id NGLSbU1wqfQx for ; Mon, 28 Mar 2022 10:20:42 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 171E01600C0 for ; Mon, 28 Mar 2022 10:20:42 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zVFa8u6st4JI for ; Mon, 28 Mar 2022 10:20:42 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E9B1C160052 for ; Mon, 28 Mar 2022 10:20:41 -0700 (PDT) Message-ID: Date: Mon, 28 Mar 2022 10:20:41 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: bug-sed@gnu.org From: Paul Eggert Organization: UCLA Computer Science Department Subject: GNU Sed 's/.../\n/' disagreement with POSIX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) POSIX says that this shell command: echo 'abc' | sed 's/b/\n/g' should output 'anc', but with GNU Sed it outputs two lines 'a' and 'c', even if POSIXLY_CORRECT is set. Traditional Sed (e.g., Solaris, AIX 7) conforms to POSIX. FreeBSD Sed agrees with GNU Sed though, and I would guess that that GNU Sed's behavior is probably more expected. However, this disagreement with POSIX should be documented in the GNU Sed manual (and the manual should recommend backslash-newline over backslash-'n' for portability), and if POSIXLY_CORRECT is set, GNU Sed should conform to POSIX. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 14:39:51 2022 Received: (at submit) by debbugs.gnu.org; 28 Mar 2022 18:39:51 +0000 Received: from localhost ([127.0.0.1]:59185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYuHP-0001Oi-A4 for submit@debbugs.gnu.org; Mon, 28 Mar 2022 14:39:51 -0400 Received: from lists.gnu.org ([209.51.188.17]:50516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nYuHO-0001Ob-NX for submit@debbugs.gnu.org; Mon, 28 Mar 2022 14:39:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYuHM-00089S-IG for bug-sed@gnu.org; Mon, 28 Mar 2022 14:39:50 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYuHK-0005pD-OK for bug-sed@gnu.org; Mon, 28 Mar 2022 14:39:48 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 95BB8160052 for ; Mon, 28 Mar 2022 11:39:44 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id m6QAX5AzOWQe for ; Mon, 28 Mar 2022 11:39:39 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0596E160097 for ; Mon, 28 Mar 2022 11:39:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YF6Bi2_D4sj3 for ; Mon, 28 Mar 2022 11:39:38 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D8C22160052 for ; Mon, 28 Mar 2022 11:39:38 -0700 (PDT) Message-ID: Date: Mon, 28 Mar 2022 11:39:38 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: GNU Sed 's/.../\n/' disagreement with POSIX Content-Language: en-US From: Paul Eggert To: bug-sed@gnu.org References: Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) On 3/28/22 10:20, Paul Eggert wrote: > POSIX says that this shell command: >=20 > =C2=A0echo 'abc' | sed 's/b/\n/g' >=20 > should output 'anc', but with GNU Sed it outputs two lines 'a' and 'c',= =20 > even if POSIXLY_CORRECT is set. Oh, a further reading of the POSIX spec indicates that the behavior is=20 unspecified here. So, please ignore what I wrote about POSIXLY_CORRECT=20 etc.; the current GNU Sed behavior is fine. Though it may be helpful to=20 document the unportability of \n here.