sed -i empty argument compatibility issue

Christian Weisgerber naddy at mips.inka.de
Tue Mar 9 15:15:16 UTC 2021


On 2021-03-05, Bob Proulx <bob at proulx.com> wrote:

> 4. Introduce a "sed" wrapper in PATH that intercepts the call to the
> real sed, detects this problematic usage case, and then DTRT does the
> right thing with it.

To save a lot of patching for the regression tests in the devel/got
port, I added this shell function:

# compat wrapper
sed()
(
        for i; do
                arg=$1
                shift
                case $arg in
                -i)     set - "$@" "$arg" '' ;;
                *)      set - "$@" "$arg" ;;
                esac
        done
        exec sed "$@"
)

No, it doesn't handle all cases, but it is good enough in that context.
ports/devel/got/files/patch-regress_cmdline_common.sh

-- 
Christian "naddy" Weisgerber                          naddy at mips.inka.de


More information about the freebsd-questions mailing list