Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Mar 2021 00:03:28 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 254091] sed: Please fix -i behavior
Message-ID:  <bug-254091-227-sgOm7jg4M7@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-254091-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-254091-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254091

--- Comment #8 from Ed Maste <emaste@freebsd.org> ---
As far as I can tell there is no compatible way to specify no backup extens=
ion
(between GNU and current FreeBSD sed), but we could have FreeBSD sed handle
both -i and -i '' (assuming that there's no legitimate other interpretation=
 of
-i '').

Maybe we can do this in a couple of steps, starting with a warning on '-i
.bak'?

something like:

                case 'i':
                        if (optarg) {
                                inplace =3D optarg;
                        } else {
                                if (optind >=3D argc)
                                        errx(1, "no arg for -i");
                                if (*argv[optind] =3D=3D '\0') {
                                        inplace =3D "";
                                } else {
                                        inplace =3D argv[optind];
                                        warnx("-i %s deprecated, use -i%s",
inplace, inplace);
                                }
                                optind++;
                        }
                }

and then later:

                case 'i':
                        if (optarg) {
                                inplace =3D optarg;
                        } else {
                                inplace =3D "";
                                // Backwards compat for historical -i ''
                                if (optind < argc && *argv[optind] =3D=3D '=
\0')
                                        optind++;
                        }
                        break;

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-254091-227-sgOm7jg4M7>