GNU bug report logs - #78883
backslash interpretation in 's' replacement text violates POSIX

Previous Next

Package: sed;

Reported by: Bruno Haible <bruno <at> clisp.org>

Date: Mon, 23 Jun 2025 21:48:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Collin Funk <collin.funk1 <at> gmail.com>
Cc: 78883 <at> debbugs.gnu.org, bruno <at> clisp.org
Subject: bug#78883: backslash interpretation in 's' replacement text violates POSIX
Date: Thu, 26 Jun 2025 18:35:24 -0700
On Mon, Jun 23, 2025 at 5:32 PM Collin Funk <collin.funk1 <at> gmail.com> wrote:
> Bruno Haible via <bug-sed <at> gnu.org> writes:
>
> > POSIX [1] is ambiguous here, I would say:
> > Quoting:
> >   "For each other <backslash> encountered, the following character shall
> >    lose its special meaning (if any)."
> > but also
> >   "The meaning of an unescaped <backslash> immediately followed by any
> >    character other than '&', <backslash>, a digit, <newline>, 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 .




This bug report was last modified 43 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.