mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:42:02 +02:00
Switch to case statement for arg parsing in le-auto.
Ported from #1751. * It's more lines but fewer tokens, less room for quote errors, and more idiomatic (see any init.d script). * Also, fix a bug in which any option containing "-v", e.g. --eat-vertical-pizza, would be construed as --verbose.
This commit is contained in:
@@ -25,18 +25,24 @@ LE_AUTO_VERSION="0.5.0.dev0"
|
|||||||
# additionally responds to --verbose (more output) and --debug (allow support
|
# additionally responds to --verbose (more output) and --debug (allow support
|
||||||
# for experimental platforms)
|
# for experimental platforms)
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
# This first clause is redundant with the third, but hedging on portability
|
case "$arg" in
|
||||||
if [ "$arg" = "-v" ] || [ "$arg" = "--verbose" ] || echo "$arg" | grep -E -- "-v+$" ; then
|
--debug)
|
||||||
VERBOSE=1
|
DEBUG=1;;
|
||||||
elif [ "$arg" = "--no-self-upgrade" ] ; then
|
--os-packages-only)
|
||||||
# Do not upgrade this script (also prevents client upgrades, because each
|
OS_PACKAGES_ONLY=1;;
|
||||||
# copy of the script pins a hash of the python client)
|
--no-self-upgrade)
|
||||||
NO_SELF_UPGRADE=1
|
# Do not upgrade this script (also prevents client upgrades, because each
|
||||||
elif [ "$arg" = "--os-packages-only" ] ; then
|
# copy of the script pins a hash of the python client)
|
||||||
OS_PACKAGES_ONLY=1
|
NO_SELF_UPGRADE=1;;
|
||||||
elif [ "$arg" = "--debug" ]; then
|
--verbose)
|
||||||
DEBUG=1
|
VERBOSE=1;;
|
||||||
fi
|
[!-]*|-*[!v]*|-)
|
||||||
|
# Anything that isn't -v, -vv, etc.: that is, anything that does not
|
||||||
|
# start with a -, contains anything that's not a v, or is just "-"
|
||||||
|
;;
|
||||||
|
*) # -v+ remains.
|
||||||
|
VERBOSE=1;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# letsencrypt-auto needs root access to bootstrap OS dependencies, and
|
# letsencrypt-auto needs root access to bootstrap OS dependencies, and
|
||||||
|
|||||||
@@ -25,18 +25,24 @@ LE_AUTO_VERSION="{{ LE_AUTO_VERSION }}"
|
|||||||
# additionally responds to --verbose (more output) and --debug (allow support
|
# additionally responds to --verbose (more output) and --debug (allow support
|
||||||
# for experimental platforms)
|
# for experimental platforms)
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
# This first clause is redundant with the third, but hedging on portability
|
case "$arg" in
|
||||||
if [ "$arg" = "-v" ] || [ "$arg" = "--verbose" ] || echo "$arg" | grep -E -- "-v+$" ; then
|
--debug)
|
||||||
VERBOSE=1
|
DEBUG=1;;
|
||||||
elif [ "$arg" = "--no-self-upgrade" ] ; then
|
--os-packages-only)
|
||||||
# Do not upgrade this script (also prevents client upgrades, because each
|
OS_PACKAGES_ONLY=1;;
|
||||||
# copy of the script pins a hash of the python client)
|
--no-self-upgrade)
|
||||||
NO_SELF_UPGRADE=1
|
# Do not upgrade this script (also prevents client upgrades, because each
|
||||||
elif [ "$arg" = "--os-packages-only" ] ; then
|
# copy of the script pins a hash of the python client)
|
||||||
OS_PACKAGES_ONLY=1
|
NO_SELF_UPGRADE=1;;
|
||||||
elif [ "$arg" = "--debug" ]; then
|
--verbose)
|
||||||
DEBUG=1
|
VERBOSE=1;;
|
||||||
fi
|
[!-]*|-*[!v]*|-)
|
||||||
|
# Anything that isn't -v, -vv, etc.: that is, anything that does not
|
||||||
|
# start with a -, contains anything that's not a v, or is just "-"
|
||||||
|
;;
|
||||||
|
*) # -v+ remains.
|
||||||
|
VERBOSE=1;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# letsencrypt-auto needs root access to bootstrap OS dependencies, and
|
# letsencrypt-auto needs root access to bootstrap OS dependencies, and
|
||||||
|
|||||||
Reference in New Issue
Block a user