Avoid bash regexps
Turns out that bash's regexps (using `=~') changed so that quoting them matches a literal string, and it seems dangerous to rely on parsing unquoted regexps. One way around this is to put the regexp in a variable, but for the two simple uses that this script had, it's easy to avoid regexps completely.
This commit is contained in:
parent
580c952e46
commit
8beba3caf9
|
@ -116,6 +116,8 @@ msets "/"
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
# make sure that everything is group-readable
|
# make sure that everything is group-readable
|
||||||
umask 002
|
umask 002
|
||||||
|
# needed for some hacks below
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
# get this script's name and path
|
# get this script's name and path
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
@ -382,7 +384,6 @@ cleanup_lockfile() {
|
||||||
# associative arrays, with names that are treated similarly to paths and a
|
# associative arrays, with names that are treated similarly to paths and a
|
||||||
# default context similar to the current directory. (Implemented as plain
|
# default context similar to the current directory. (Implemented as plain
|
||||||
# variables, using "__" as the translation of "/" level separators.)
|
# variables, using "__" as the translation of "/" level separators.)
|
||||||
shopt -s extglob # needed for some hacks below
|
|
||||||
mcontext="/" # the current context for m-ops
|
mcontext="/" # the current context for m-ops
|
||||||
mset() {
|
mset() {
|
||||||
# mset goes over all args, which can have the following shapes:
|
# mset goes over all args, which can have the following shapes:
|
||||||
|
@ -497,9 +498,9 @@ is_yes() {
|
||||||
while true; do
|
while true; do
|
||||||
echo_n ">>> QUESTION >>> $var [y/n/Y/N] ? " 1>&2
|
echo_n ">>> QUESTION >>> $var [y/n/Y/N] ? " 1>&2
|
||||||
if [[ "$fixed_reply" != "" ]]; then reply="$fixed_reply"
|
if [[ "$fixed_reply" != "" ]]; then reply="$fixed_reply"
|
||||||
elif [[ "$ask_answers" =~ "^(.)(.*)$" ]]; then
|
elif [[ "x$ask_answers" != "x" ]]; then
|
||||||
reply="${BASH_REMATCH[1]}"
|
reply="${ask_answers:0:1}"
|
||||||
ask_answers="${BASH_REMATCH[2]}"
|
ask_answers="${ask_answers:1}"
|
||||||
else read -sn 1 reply; fi
|
else read -sn 1 reply; fi
|
||||||
echo "$reply" 1>&2
|
echo "$reply" 1>&2
|
||||||
case "$reply" in
|
case "$reply" in
|
||||||
|
@ -995,7 +996,7 @@ MAIN_BUILD() {
|
||||||
htmltimestamp="$(date '+updated at %A, %B %d %Y, %H:%M %Z')"
|
htmltimestamp="$(date '+updated at %A, %B %d %Y, %H:%M %Z')"
|
||||||
if [[ "$1" = "ask" ]]; then
|
if [[ "$1" = "ask" ]]; then
|
||||||
ask_mode="yes"; shift
|
ask_mode="yes"; shift
|
||||||
if [[ "$1" =~ "[yYnN ][yYnN ]*" ]]; then
|
if [[ "$1" = +([yYnN ]) ]]; then
|
||||||
ask_answers="$(echo "$1" | tr -d ' ')"; shift
|
ask_answers="$(echo "$1" | tr -d ' ')"; shift
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user