Some bash versions (notably at least 5.1) reset BASH_COMPAT to the default value (for 5.1, that's 51) if a compat shell option is unset, even if it was previously unset. Normally, such a sequence should be a no-op, but due to the bug, it isn't.
Work around this by saving the ${BASH_COMPAT} value before the eval "$(shopt -p)" call and restore it if ${BASH_COMPAT} does not match the original value any longer.
Some bash versions (notably at least 5.1) reset
BASH_COMPAT
to the default value (for 5.1, that's51
) if a compat shell option is unset, even if it was previously unset. Normally, such a sequence should be a no-op, but due to the bug, it isn't.Work around this by saving the
${BASH_COMPAT}
value before theeval "$(shopt -p)"
call and restore it if${BASH_COMPAT}
does not match the original value any longer.Just a safe bugfix, merging right away.