mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2025-01-31 23:35:20 +00:00
Put comments on own line
This commit is contained in:
parent
ff907092a3
commit
cbe70aa80e
21
main.sh
21
main.sh
@ -154,15 +154,22 @@ OPTIND=1
|
||||
while getopts "${opts}" opt; do
|
||||
[ "${opt}" = "?" ] && help "Invalid use of script: ${@} "
|
||||
|
||||
if [ "${opt}" = "-" ]; then #OPTARG is long-option-name or long-option=value
|
||||
if [[ "${OPTARG}" =~ .*=.* ]]; then # --key=value format
|
||||
if [ "${opt}" = "-" ]; then
|
||||
# OPTARG is long-option-name or long-option=value
|
||||
if [[ "${OPTARG}" =~ .*=.* ]]; then
|
||||
# --key=value format
|
||||
long=${OPTARG/=*/}
|
||||
eval "opt=\"\${short_opt_${long}}\"" # Set opt to the short option corresponding to the long option
|
||||
# Set opt to the short option corresponding to the long option
|
||||
eval "opt=\"\${short_opt_${long}}\""
|
||||
OPTARG=${OPTARG#*=}
|
||||
else # --key value format
|
||||
eval "opt=\"\${short_opt_${OPTARG}}\"" # Map long name to short version of option
|
||||
eval "OPTARG=\"\${@:OPTIND:\${has_arg_${opt}}}\"" # Only assign OPTARG if option takes an argument
|
||||
((OPTIND+=has_arg_${opt})) # shift over the argument if argument is expected
|
||||
else
|
||||
# --key value format
|
||||
# Map long name to short version of option
|
||||
eval "opt=\"\${short_opt_${OPTARG}}\""
|
||||
# Only assign OPTARG if option takes an argument
|
||||
eval "OPTARG=\"\${@:OPTIND:\${has_arg_${opt}}}\""
|
||||
# shift over the argument if argument is expected
|
||||
((OPTIND+=has_arg_${opt}))
|
||||
fi
|
||||
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user