From c79ee2ff79930d90b58d07b1a32cac4fde627766 Mon Sep 17 00:00:00 2001 From: DJ Lucas Date: Sat, 7 Aug 2021 00:40:39 -0500 Subject: [PATCH] make-ca: Handle getopt style short options in get_args(). --- CHANGELOG | 1 + make-ca | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 94dacee..cf13771 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ - Fix output of NSSDB and Java PCKS#12 stores - Correct incorrectly named get_p11_val() - Use p11label value and .p11-kit extension for anchor naming + - Handle getopt style short options in get_args() 1.7 - Revert help2man update (requires complete perl environment) 1.6 - Fix install target for make -j# - Add detailed dependency info and add note about configuration file diff --git a/make-ca b/make-ca index 5760b15..c8bfca5 100644 --- a/make-ca +++ b/make-ca @@ -9,6 +9,8 @@ # Bruce Dubbs # Graham Weldon +shopt -s extglob; + VERSION="1.8" MAKE_CA_CONF="/etc/make-ca.conf" @@ -218,6 +220,17 @@ function get_args(){ echo -e "$(basename ${0}) ${VERSION}\n" exit 0 ;; + # Handle getopt style short args (use extglob instead of loop) + -+([a-z,A-Z])) + # split up the arguments and call recursively with trailing break + arg="${1}" + newargs=$( echo ${1} | sed 's@-@@' | \ + sed 's/.\{1\}/& /g' | \ + sed 's/[^ ]* */-&/g') + newargs="${newargs} $(echo ${@} | sed "s@${arg}@@")" + get_args ${newargs} + break; + ;; *) showhelp exit 1