[Bug 254091] sed: Please fix -i behavior

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Mar 8 00:03:28 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254091

--- Comment #8 from Ed Maste <emaste at freebsd.org> ---
As far as I can tell there is no compatible way to specify no backup extension
(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 = optarg;
                        } else {
                                if (optind >= argc)
                                        errx(1, "no arg for -i");
                                if (*argv[optind] == '\0') {
                                        inplace = "";
                                } else {
                                        inplace = argv[optind];
                                        warnx("-i %s deprecated, use -i%s",
inplace, inplace);
                                }
                                optind++;
                        }
                }

and then later:

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

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


More information about the freebsd-bugs mailing list