aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2022-11-01 20:38:08 +0100
committerThomas Lange <code@nerdmind.de>2022-11-01 21:16:15 +0100
commit35215a4678627f29fe791d51e71d5cc0dd4840f7 (patch)
tree2a0e1aef0ef443cc649195799a6e53c3642b2d28
parent946a445d24a0f9b9e8519968bc47dcd15df09f11 (diff)
downloadpainlessle-35215a4678627f29fe791d51e71d5cc0dd4840f7.tar.gz
painlessle-35215a4678627f29fe791d51e71d5cc0dd4840f7.tar.xz
painlessle-35215a4678627f29fe791d51e71d5cc0dd4840f7.zip
Process command-line options without getopts
The "getopts" shell built-in works perfectly with short options but does not support long options, unfortunately. To be more flexible when adding new options, get rid of "getopts" and use a traditional loop instead.
-rwxr-xr-xpackage/sbin/painless-le22
1 files changed, 11 insertions, 11 deletions
diff --git a/package/sbin/painless-le b/package/sbin/painless-le
index 2a0a75f..177662d 100755
--- a/package/sbin/painless-le
+++ b/package/sbin/painless-le
@@ -22,28 +22,28 @@
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
#===============================================================================
-# Define ACME endpoint address and BEFORE/AFTER commands
+# Define ACME endpoint URL
#===============================================================================
ACME_ENDPOINT="https://acme-v02.api.letsencrypt.org/directory"
#ACME_ENDPOINT="https://acme-staging-v02.api.letsencrypt.org/directory"
#===============================================================================
-# Normalize command-line arguments with GNU getopt
+# Normalize command-line argument string
#===============================================================================
eval set -- "$(getopt -o K:I:C:F: -- "$@")"
#===============================================================================
-# Parse command-line options with getopts
+# Parse command-line options
#===============================================================================
-while getopts :K:I:C:F: option
-do
- case $option in
- K) OPT_CONFIDENTIAL="$OPTARG" ;;
- I) OPT_INTERMEDIATE="$OPTARG" ;;
- C) OPT_CERTIFICATE_ONLY="$OPTARG" ;;
- F) OPT_CERTIFICATE_FULL="$OPTARG" ;;
+while true; do
+ case "$1" in
+ -K) OPT_CONFIDENTIAL="$2"; shift 2;;
+ -I) OPT_INTERMEDIATE="$2"; shift 2;;
+ -C) OPT_CERTIFICATE_ONLY="$2"; shift 2;;
+ -F) OPT_CERTIFICATE_FULL="$2"; shift 2;;
+ --) shift; break;;
esac
-done; shift $((OPTIND-1))
+done
#===============================================================================
# Set positional argument variables