From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 23 17:47:03 2025 Received: (at submit) by debbugs.gnu.org; 23 Jun 2025 21:47:04 +0000 Received: from localhost ([127.0.0.1]:59848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uTp0J-0000QN-20 for submit@debbugs.gnu.org; Mon, 23 Jun 2025 17:47:03 -0400 Received: from lists.gnu.org ([2001:470:142::17]:35140) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uTp0G-0000Oc-Hr for submit@debbugs.gnu.org; Mon, 23 Jun 2025 17:47:01 -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 1uTp08-0008VA-SP for bug-sed@gnu.org; Mon, 23 Jun 2025 17:46:52 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.218]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uTp06-0006E3-SV for bug-sed@gnu.org; Mon, 23 Jun 2025 17:46:52 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1750715208; cv=none; d=strato.com; s=strato-dkim-0002; b=oV7swWsB8mGAROW1XXrO1Xha0xsRxjtSx66ZiT77J4hnEQ69evjmGIvSJPAyT0aQpx wnjreGk+sMbQfq9ZnT15Rm4glDeKTOIPF7HvLvNuHqNIGeAtfwJTs9fLjxoQtQBWAAAs 0FpvnExlpUsXiTixS7IVJAeVVvP2yDxJdfDoe+WQmdFL1zjtLw0x0FqkwC1NS1EA/TSE Sso3VxCvLFvcsxcaoygE98PufnD/Z2nqeCrBP2GvgmBE1E63fIZ0E1wiTHPBM0jpc2Wd nboFABM3S1JKjXEY8ZgsPb52EM9Gi78uWgD2P6ajgS7cdbz/9RkXgZFD2EZIDumflK5+ jvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1750715208; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=jDligXpnFl+C+xzgJaMCEeTlF22HXgff2K3tQtA0owg=; b=r2Phxef8G4D4OlS9Gf5FBf2SzVhk2ZH37pCmFRrQ3tv7ZdzQ+e2OnhTtu/50C28IGF nfAYMk/CbtQtmzLwUmpydUY5eXuTy6VUpYhIWf2txAGfCQr8xlZdamxTgdKueaf4wisW w8vsj/67XrLGfaCzGVGHoUwgPkQoZV/gQKhJyrMr+qWbzXF5Z3JGNKijwjX/k1k5lL/U 4O6C5EdDbo5WbgKGXrFjhoE35v33aUD1vd8eCnH9BI2ZgDrqXSFY6gOSn2wwU71Tw1Jr SDh1iF9k4S7HzSrxrA1VGu4LUKFTPqaYGKWnqqQU2763H7SVDbmbj2AOEEfcjFM5UHOc FGbA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1750715208; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=jDligXpnFl+C+xzgJaMCEeTlF22HXgff2K3tQtA0owg=; b=HUZEPsFBS5fkZsDceEBdvpriX50u+G11U4QJyqOXaPUdOQ7tg34aVuTVei8JJt9pOd 8vF6Ltyx1tZ0n2TL58+ysc0Gek03fpHIdPBjEzxo9p2g8esI1Tbi0WAb9BwRgNQ+sc8J uG4h9euNuNG3S9I5mGslDEq9M07FH1pRDxm08pp8Xk9KpOyVyIJgduYy+clZJJpbyR1H +VRbk0dG4OzFqXBna4ncAKjvB5D85SudFxNbIa70Wr4qeHDus+2RBPyVKHnbpHTjLIsN vTuFkbpDhRmhndK6aKNnL09fezShEeMfEexp20adhzSIpKJ6jzG9oH+UThJXNtKt742N 9TXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1750715208; s=strato-dkim-0003; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=jDligXpnFl+C+xzgJaMCEeTlF22HXgff2K3tQtA0owg=; b=Z8oShrvt6d8XhgjLPmizs3loAcD4YYLhTc1cthri5fXEzHmCgPv1M0Ngu9952ZYZFu dfGlyVqg0PuCELk+9BBA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlLnY4jECd2hdUURIbZgL8PX2QiTuZ3cdB8X/nqjibHW73lOkh7BNGaIKC7XtCN6Y=" Received: from nimes.localnet by smtp.strato.de (RZmta 51.3.0 AUTH) with ESMTPSA id N7dcf815NLklmHl (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 23 Jun 2025 23:46:47 +0200 (CEST) From: Bruno Haible To: bug-sed@gnu.org Subject: backslash interpretation in 's' replacement text violates POSIX Date: Mon, 23 Jun 2025 23:46:47 +0200 Message-ID: <3138927.5y6ypk8feq@nimes> Organization: GNU MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.218; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.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: -1.0 (-) Hi, When the replacement text in an 's' command contains an escape sequence like '\n', GNU sed interprets this escape sequence, while other implementations (OpenBSD sed, Solaris sed) do not. How to reproduce: $ echo foo | sed -e 's/f.*/line1\nline2/' line1 line2 $ echo foo | POSIXLY_CORRECT=1 sed --posix -e 's/f.*/line1\nline2/' line1 line2 Seen with GNU sed 4.9. While OpenBSD sed, Solaris sed produce: $ echo foo | sed -e 's/f.*/line1\nline2/' line1nline2 POSIX [1] is ambiguous here, I would say: Quoting: "For each other encountered, the following character shall lose its special meaning (if any)." but also "The meaning of an unescaped immediately followed by any character other than '&', , a digit, , or the delimiter character used for this command, is unspecified." So the interpretation of escape sequences looks like a GNU extension. By the description of the '--posix' option ("In order to simplify writing portable scripts"), the --posix option should turn off this interpretation. Or, better, emit a diagnostic. Bruno [1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 23 20:31:08 2025 Received: (at submit) by debbugs.gnu.org; 24 Jun 2025 00:31:08 +0000 Received: from localhost ([127.0.0.1]:33849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uTrZ5-0003ip-Ls for submit@debbugs.gnu.org; Mon, 23 Jun 2025 20:31:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41238) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uTrZ4-0003hR-7r for submit@debbugs.gnu.org; Mon, 23 Jun 2025 20:31:06 -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 1uTrYv-0002jn-LV for bug-sed@gnu.org; Mon, 23 Jun 2025 20:30:57 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uTrYu-0000Zy-4t for bug-sed@gnu.org; Mon, 23 Jun 2025 20:30:57 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-b31c6c9959cso5128552a12.1 for ; Mon, 23 Jun 2025 17:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750725054; x=1751329854; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cg+hl2H0TWE6/9+RyprUejHSUG39nWuwdt/zVf95TKY=; b=YkHWTperMQH3DEMohENvCOjGq9wapnWeMc8zHti7/c17C8HELC6Aatqu0SRXb16gbT 4GLwIQQXHgaVdrVKXSPYlZspBi0Lig7qQxRy9Duh8aHEmIU1wriLiqBB5HqWgwFsZsh4 PRvfGfnaK7y9CJyz+FIojU+V+0/S1n5F1Nqjq3KsJmhkhyf1a5SpRkQ7F9KGaBaJ5Ujn JqI1vj9bWbWvD/HNrcTBWF7Wi2Ff6y92qK4Kz0ni9zjSVxYrt1VGbG5p9eLnHVwHs2na yi04Rg2EVUj/HKkXMg+B29o8yP3aX4aLbbq4lqIlX0SFuuIs0DKqNewjmhGceksXt51L IR8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750725054; x=1751329854; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Cg+hl2H0TWE6/9+RyprUejHSUG39nWuwdt/zVf95TKY=; b=Xa8lCZ1hTyFgYSgnBHpgrG1oPgqGq4ceWHNXgHWVozQm+7V+6n50yNQKgrXJOBVOgY x4AxFEizFjRweUVIVJ0rYPx9BXbYSjgpr9g7J6a8sbVa3GZNbMK+xBBUE2yM/OHJz5+x /9/NgIKepjUa9WbhHXDU9Uanty9/VcnMoPXM7Acwp2uMfht4XtGS9DzZkDAAWJ8KmrTc fhU+eFfPcjLCbSLwRIya1dDe8fqobuQMZorZ8XXk+BB65RJM2WHk0J+c4YtDfPmz2s7e 7G4LyZjx8EWURhOmRuFHhA6yw7+1dOhwbbkQ1HtgVuyzlX2lKZh1x24wxTY+vH4Kpk7o oCsA== X-Gm-Message-State: AOJu0YwvIUfko9BvBpk9UzcvsQG73BoxY60jvx9W/MPh8jivF4BI6R7A yEcTtiS3lgiCJjrYRND4QVMtO6druesHzaiLyj0Wq2fusQyTaJa9Y+Zj9VOtzg== X-Gm-Gg: ASbGncs25GhrimQbGNCtBSear6KauU93LyLXQ5Wd5N8FTOIc6RXhBsYzzPe5PsaEiXU 10zishmT7ldbza6EUkTqGzCVnr3LuYLBBUsIwNCO0kaqoiNKJJyrUDeOU87Y7y80qyVbi4BSMpE wosyX6YG3APhxRdE/kr2NUiFu6etVL/iVP8VBwtI/tDijBS24sr+R91MNr5IPgjxLqkQclzEndJ KCmfws3ZokaSCYWsIFPWTJl4xb23FaBV6zxpD1w+b+lDv+Do8XvwS+6aOLaRjAEfxCxIKmVGuhF IEL1TpWFr560XdKEyc3Fi56LmrkEhDBlKlh/mid1iJw= X-Google-Smtp-Source: AGHT+IEpAHQFUJhu+CohMHcX+qlqr6ztbCz6GxBbbFVt/xIt2K83IDN8hcIPentJy+bqWS1ArwHszw== X-Received: by 2002:a05:6a20:9e48:b0:220:21bd:75c6 with SMTP id adf61e73a8af0-22026ed2720mr17650676637.33.1750725054405; Mon, 23 Jun 2025 17:30:54 -0700 (PDT) Received: from fedora ([2601:646:8081:3770::1707]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b31f12584e1sm8964017a12.59.2025.06.23.17.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jun 2025 17:30:54 -0700 (PDT) From: Collin Funk To: Bruno Haible via Subject: Re: bug#78883: backslash interpretation in 's' replacement text violates POSIX In-Reply-To: <3138927.5y6ypk8feq@nimes> References: <3138927.5y6ypk8feq@nimes> Date: Mon, 23 Jun 2025 17:30:53 -0700 Message-ID: <87pleuhtfm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=collin.funk1@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, 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.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Bruno Haible via writes: > POSIX [1] is ambiguous here, I would say: > Quoting: > "For each other encountered, the following character shall > lose its special meaning (if any)." > but also > "The meaning of an un [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (collin.funk1[at]gmail.com) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (collin.funk1[at]gmail.com) 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-Debbugs-Envelope-To: submit Cc: 78883@debbugs.gnu.org, Bruno Haible 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.2 (/) Bruno Haible via writes: > POSIX [1] is ambiguous here, I would say: > Quoting: > "For each other encountered, the following character shall > lose its special meaning (if any)." > but also > "The meaning of an unescaped immediately followed by any > character other than '&', , a digit, , or the > delimiter character used for this command, is unspecified." > > So the interpretation of escape sequences looks like a GNU extension. > > By the description of the '--posix' option ("In order to simplify > writing portable scripts"), the --posix option should turn off this > interpretation. Or, better, emit a diagnostic. Just want to add a strong +1 for keeping it as a GNU extension. I find it annoying that other systems 'sed' command does not behave the same way. I'm fine with adding a warning for when '--posix' is used though. That would be helpful for scripts that aim to be as portable as possible (e.g. the old gnulib-tool). Collin From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 23 20:41:17 2025 Received: (at submit) by debbugs.gnu.org; 24 Jun 2025 00:41:17 +0000 Received: from localhost ([127.0.0.1]:33980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uTriv-0004xk-5n for submit@debbugs.gnu.org; Mon, 23 Jun 2025 20:41:17 -0400 Received: from lists.gnu.org ([2001:470:142::17]:38554) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uTris-0004wc-Ct for submit@debbugs.gnu.org; Mon, 23 Jun 2025 20:41:15 -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 1uTrij-0004Aj-Ly for bug-sed@gnu.org; Mon, 23 Jun 2025 20:41:05 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.163]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uTrii-0001Yd-40 for bug-sed@gnu.org; Mon, 23 Jun 2025 20:41:05 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1750725657; cv=none; d=strato.com; s=strato-dkim-0002; b=C20qg4+B1UIKb7tnqcN4uMGPCfhZei71g2m6xNJRURULtb6hmcK0dvgqndFj1ZmXEf vfXZeeL+3qN1PECUYa0g/p84JozaN05Km9Kk1LtQ0IQ/uI0w8EBxAB0OnVV4bJWB05w8 FBOQUX6Gu6HjXdAb2ydtA3kmaTriDPYttphgCt0+1ieyOA9h373VJTh83MlUtN6/gOef B0b5ijYYyGjkaR5MGwDT4bU6cqU45sfgPxpSRgstGaKyDIL3pi02BD9RynBTGSs+blga JFOmLNXh6mXInBGFJq87KuUUlLD6VyWdB9pHz59HOPu1r8DF3snLRpE0xD7puqRMVKeK wPFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1750725657; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=guBTATB4+u+4fvqqBPwY4KIdd/KWEVXrSmEEMq+iPxk=; b=NxRsyBuS63C9UUzULnFCkPoe3MpQfefXL1uizB9M5ClJVyNuw4ke64gk3F1Zt0k00Z zu36fDAPZVC2b//vrRty7lbMpPmLLTPNj/AWoS5dyA/YuK3fZCtP3a60/FxnHd/rq6BR 3xkH05KwgpwsoKJGb8lOfUk81qwGhB3/r2yQCFJr8fuuafa67Na+UkcyRFtZk74BYo9F ZO/s0T0mzpoIbv/A+dYIaW9+7Qsnr99Ex+5YU5eZK3T8kuomr9cSF953fg8pd6ssF373 xpWatVdvMT1FQXrgIqNJ54SDnlFzyXKxeZFtt6VPu3OWUHPVDwhY092J6gmnxsXQhZws BSVA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1750725657; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=guBTATB4+u+4fvqqBPwY4KIdd/KWEVXrSmEEMq+iPxk=; b=sM7klYRPCPxfUwidTZVV224LoeEMpn6hJQbkvO4PWvTU2+tAadcAsORdErtIG4idew GbZ2ICVH0MToMt40wuQu/zwfnv0dOkX9OowDsDae3aqW6bGwL6MRElmUGqUpXQoVg9jT gDqr533ZixEwtdQtfNtiE0TCJSButWXk610/YUhk7o34KN0yrvRiA0spg8YIhkyCZ4yn 5swwnlGs9oyTBkGYIYKIPXC3iCY/5Csb8yRQRJ9Bs0uVS63dE0IHVLsDZRtez4J3hlCT 56UcCvvPZjzuOM69qD0XxgFJnb8N+hzGQrtqslfzRHcuEzCQ9mnSTRDZWDzHmPDRhnvx VwxQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1750725657; s=strato-dkim-0003; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=guBTATB4+u+4fvqqBPwY4KIdd/KWEVXrSmEEMq+iPxk=; b=NJ0U4CBrnpGhSHwjm7dpYMtAWkiMrAJ4f4dg69peXrZGCyxBpq96/+Unppd5uZ89Gu 4HASKQyVyVeU72pigKDA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlLnY4jECd2hdUURIbZgL8PX2QiTuZ3cdB8X/nqjibHW73lOkh7BNGaIKC7XtCN6Y=" Received: from nimes.localnet by smtp.strato.de (RZmta 51.3.0 AUTH) with ESMTPSA id N7dcf815O0evmWd (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 24 Jun 2025 02:40:57 +0200 (CEST) From: Bruno Haible To: bug-sed@gnu.org Subject: Re: bug#78883: backslash interpretation in 's' replacement text is a portability problem Date: Tue, 24 Jun 2025 02:40:57 +0200 Message-ID: <4165551.OK3tgjcQNu@nimes> Organization: GNU In-Reply-To: <87pleuhtfm.fsf@gmail.com> References: <3138927.5y6ypk8feq@nimes> <87pleuhtfm.fsf@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.163; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit Cc: 78883@debbugs.gnu.org, Collin Funk 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: -1.0 (-) Correcting the title. It's probably not a POSIX violation (as I initially thought). Rather, it's a portability problem; and this is where the '--posix' option becomes relevant. Bruno From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 26 21:35:46 2025 Received: (at 78883) by debbugs.gnu.org; 27 Jun 2025 01:35:47 +0000 Received: from localhost ([127.0.0.1]:55947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uUy0I-0001YM-Ej for submit@debbugs.gnu.org; Thu, 26 Jun 2025 21:35:46 -0400 Received: from mail-pg1-f181.google.com ([209.85.215.181]:48203) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uUy0E-0001X5-Mx for 78883@debbugs.gnu.org; Thu, 26 Jun 2025 21:35:43 -0400 Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-b3182c6d03bso1948818a12.0 for <78883@debbugs.gnu.org>; Thu, 26 Jun 2025 18:35:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750988136; x=1751592936; h=content-transfer-encoding:cc: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=4b8sKrAwI8JvRwwD7fWXvG3iBjurFtoZZ0gSyI9AuCA=; b=qKarKWEMsz9SedcU3tF0AXv9iJ79LSiGdiI3dxkEUBtmcfuhPVTqYGg+hyx3ST2WEf ipD4YxQ9ZTNjeTSR6aueNB6ZiOj514jJfiZs6DZ39gDqcY2ztBbNMBL8bHMcKR503UOA wVor0yNxNd7ocOwioMtUOWR07b61gKEAExiiPYhFNpb0N8JJucvzf43RPeX1Ey1LKbUp dgj1X1MZHkg3K3Lod2xODMALZzUwF7PzkhjfP3R+BVeICXdkhIc6jsEMGJZs3cI8tVSa cWFHoTK9ctzePtn7v3bNUhKT0AMRWuTpoOadpEpIEK3AgKvQ2WARyrg4KnxEYOytoo/h mRDQ== X-Gm-Message-State: AOJu0Ywd8tTELbEHMeM4DN56HnMRGGhPRVgtFm5l6D/9HNJ402UUk64I PI/b3mMBbPa/mgnV6LZdBLA9RAV0VGU50F8iO6pxU2Ask1g2TW1iC8dcCevE9KKwjBPW1n02fqV i0KI+v+JmtjVOSMV0EMe8AaD3x7pS/cg= X-Gm-Gg: ASbGncteMtWTvysCOlIdPe9vQntVOpcL0GTxA8SAvOJfOS5YaUT/pDq9E2z5IBXbcuy uRGQSi0cyygzy523l80auZsNaxx1YDvET6akj2ZvJDVLbB7gYNSEIzcDVz9EwX12NbIJsP66yhz AUfXpJ51YEinSU/VLwP2PdpQZ74ByeSmEV7Ext6WRi X-Google-Smtp-Source: AGHT+IHvPL0Vfe2t0ForJCOuGXE9bq969oh2Vq7fF/RwVEKNGsY6eJMMNByBrFvX8W33ofWA5qNSxsoT3zsXCXcYHYI= X-Received: by 2002:a17:90b:2888:b0:315:7ddc:4c2a with SMTP id 98e67ed59e1d1-318c8fef4f4mr2049259a91.12.1750988136503; Thu, 26 Jun 2025 18:35:36 -0700 (PDT) MIME-Version: 1.0 References: <3138927.5y6ypk8feq@nimes> <87pleuhtfm.fsf@gmail.com> In-Reply-To: <87pleuhtfm.fsf@gmail.com> From: Jim Meyering Date: Thu, 26 Jun 2025 18:35:24 -0700 X-Gm-Features: Ac12FXy_QURGDmJoqZfmSjZx9kIW1aqEmwGd5X674XR4a9Jp4Q1QL-9LHKnwIp0 Message-ID: Subject: Re: bug#78883: backslash interpretation in 's' replacement text violates POSIX To: Collin Funk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78883 Cc: 78883@debbugs.gnu.org, bruno@clisp.org 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: -1.0 (-) On Mon, Jun 23, 2025 at 5:32=E2=80=AFPM Collin Funk wrote: > Bruno Haible via writes: > > > POSIX [1] is ambiguous here, I would say: > > Quoting: > > "For each other encountered, the following character shal= l > > lose its special meaning (if any)." > > but also > > "The meaning of an unescaped immediately followed by any > > character other than '&', , a digit, , or the > > delimiter character used for this command, is unspecified." > > > > So the interpretation of escape sequences looks like a GNU extension. > > > > By the description of the '--posix' option ("In order to simplify > > writing portable scripts"), the --posix option should turn off this > > interpretation. Or, better, emit a diagnostic. > > Just want to add a strong +1 for keeping it as a GNU extension. I find > it annoying that other systems 'sed' command does not behave the same > way. > > I'm fine with adding a warning for when '--posix' is used though. That > would be helpful for scripts that aim to be as portable as possible > (e.g. the old gnulib-tool). I too like the prospect of a warning with --posix .