-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions
68 lines (57 loc) · 1.34 KB
/
options
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Used for both "shopt" and "set -o" options
#
### shopts ###################################################################
OPT_SHOPTS_SET=(
failglob
cdable_vars
cdspell
checkhash
checkwinsize
expand_aliases
extglob
histappend
histreedit
hostcomplete
huponexit
interactive_comments
mailwarn
promptvars
shift_verbose
cmdhist
)
OPT_SHOPTS_UNSET=(
nullglob
execfail
histverify
nocaseglob
sourcepath
lithist # currently history parsing stuff is line-based
)
### options ##################################################################
OPT_SETOPTS_UNSET=()
OPT_SETOPTS_SET=(
noclobber
)
# instead just always define the pattern as var='pattern' and use
# [[ $foo =~ $pattern ]]
#
#if (((${BASH_VERSINFO[0]} == 3 && \
# ${BASH_VERSINFO[1]} >= 2 && \
# ${BASH_VERSINFO[2]} >= 39) || \
# (${BASH_VERSINFO[0]} > 3)))
#then
# OPTS_SHOPTS_SET+=(compat31)
#fi
# new bash4 features
if ((${BASH_VERSINFO[0]} >= 4)); then
OPT_SHOPTS_SET+=(globstar)
fi
##############################################################################
# now actually set the values; only errors will be reported
#
shopt -qs ${OPT_SHOPTS_SET[@]} || return 1
shopt -qu ${OPT_SHOPTS_UNSET[@]} || return 2
set -o ${OPT_SETOPTS_SET[@]} > /dev/null || return 3
set +o ${OPT_SETOPTS_UNSET[@]} > /dev/null || return 4
unset OPT_{SET,SH}OPTS_{,UN}SET