-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_shoptions
More file actions
executable file
·35 lines (33 loc) · 962 Bytes
/
cache_shoptions
File metadata and controls
executable file
·35 lines (33 loc) · 962 Bytes
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
#!/usr/bin/env bash
if [ "$1" = '--help' ]; then
exit 1
elif [ "$1" = '--version' ]; then
exit 1
fi
condition() {
if [[ $(shopt "$1") =~ on$ ]]; then
if [ "$2" = "off" ]; then echo -n 'false'; else echo -n 'true'; fi
else
if [ "$2" = "off" ]; then echo -n 'true'; else echo -n 'false'; fi
fi
}
declare -A CACHED_SHOPTIONS=()
# echo -n '( '
# is_first='true'
for opt in "$@"; do
CACHED_SHOPTIONS[$opt]=$(condition "$opt")
# if $($is_first); then
# is_first='false'
# else
# echo -n "${IFS:0:1}"
# fi
# echo -n "[${opt}]=$(condition "$opt")"
# echo -n " [${opt}_on]=$(condition "$opt")"
# echo -n " [${opt}_off]=$(condition "$opt" off)"
done
# echo ' )'
declare -r CACHED_SHOPTIONS
declare -p CACHED_SHOPTIONS
# exit
# readonly patsub_replacement_off=$( if [[ $(shopt patsub_replacement) =~ on$ ]]; then echo 'false'; else echo 'true'; fi )
# readonly extglob_off=$( if [[ $(shopt extglob) =~ on$ ]]; then echo 'false'; else echo 'true'; fi )