lib/utils: Correctly restore shopt states in Bash < 4.1

This commit is contained in:
Koichi Murase
2022-01-15 18:31:46 +09:00
parent e21cebd52b
commit 088eee2abd

View File

@@ -231,6 +231,21 @@ pushover () {
"${PUSHOVERURL}" > /dev/null 2>&1
}
## @fn _omb_util_get_shopt optnames...
if ((_omb_bash_version >= 40100)); then
_omb_util_get_shopt() { shopt=$BASHOPTS; }
else
_omb_util_get_shopt() {
shopt=
local opt
for opt; do
if shopt -q "$opt" &>/dev/null; then
shopt=${shopt:+$shopt:}$opt
fi
done
}
fi
_omb_util_add_prompt_command() {
# Set OS dependent exact match regular expression
local prompt_re
@@ -256,7 +271,8 @@ _omb_util_add_prompt_command() {
}
_omb_util_glob_expand() {
local set=$- shopt=$BASHOPTS gignore=$GLOBIGNORE
local set=$- shopt gignore=$GLOBIGNORE
_omb_util_get_shopt failglob nullglob extglob
shopt -u failglob
shopt -s nullglob