Re: [PATCH v2] t: allow use of "sed -E"
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Mar 12, 2026, 09:26 UTC
- Message-ID
- <abKG1U3fVuNV1w_9@fruit.crustytoothpaste.net>
- In-Reply-To
- <xmqq3425lvtq.fsf@gitster.g>
On 2026-03-12 at 00:45:21, Junio C Hamano wrote:
Show 14 quoted lines
> Since early 2019 with e62e225f (test-lint: only use only sed [-n] > [-e command] [-f command_file], 2019-01-20), we have been trying to > limit the options of "sed" we use in our tests to "-e <pattern>", > "-n", and "-f <file>". > > Before the commit, we were trying to reject only "-i" (which is one > of the really-not-portable options), but the commit explicitly > wanted to reject use of "-E" (use ERE instead of BRE). The commit > cites the then-current POSIX.1 (Issue 7, 2018 edition) to show that > "even recent POSIX does not have it!", but the latest edition (Issue > 8) documents "-E" as an option to use ERE. > > But that was 7 years ago, and that is a long time for many things to > happen.
I think this seems reasonable. I know this works on both reasonably new Linux machines and on macOS, and I did some spot checking with the FreeBSD manual page viewer[0] and it's present in the following:
* at least FreeBSD 9.0 (current is 15.0) * at least NetBSD 7.0 (current is 10.1) * at least OpenBSD 6.0 (current is 7.8) * Ubuntu 18.04
so this appears to be reasonably well supported across major open source distributions. The irony is that Linux is most likely the OS holding us back here, since older versions labeled this `-r` and the newer `-E` wasn't available in Ubuntu 16.04. I myself only recently learned about the fact that `-E` had been officially standardized, since I'd been using `-r` for a long time.
And, for the record, I agree with you that `-i` is totally non-portable because it _requires_ an argument on BSD sed and the argument is optional on GNU sed (and cannot be specified as ''). I have a testsuite at work where I gave up and just used `perl -i` instead.
Show 5 quoted lines
> Besides, we have been using "sed -E" without the check in question > triggering in one of the scripts since 2022, with 461fec41 (bisect > run: keep some of the post-v2.30.0 output, 2022-11-10). It was > hidden because the 'E' was squished with another single letter > option.
Yes, I think if nobody has complained about it in three years, we should be fine.
[0] https://man.freebsd.org/cgi/man.cgi
-- brian m. carlson (they/them) Toronto, Ontario, CA