MSYS2 bash falls when substitution with pipe inside the loop

Viewed 215

The next command I'm trying to execute in MSYS2 x64 and Cygwin64 bash, in the console and as /bin/sh script.

for a in 0; do
    echo b=$(echo "c-d" | tr - _)
done

Get the output: b=
When the expected: b=c_d

And sh.exe.stackdump file with STATUS_STACK_OVERFLOW exception. This occurs only within a loop, with substitution and with a pipe, with any operation on the line: tr, grep, sed. Bash version 4.4.12 (the last to date).

It is an altered part of the ffmpeg configure script, parse options, which was previously run with no errors in the same Cygwin build.

The original script is

for opt do
    case "$opt" in
        #...
        --enable-?*|--disable-?*)
            eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
            #...
        ;;
        #...
     esac
done

Is there a way to fix this with bash options?

1 Answers

Maybe - is taken as an option try -- to specify the end of options:

tr -- - _
Related