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
|
while getopts "${opts}" opt; do
|
||||||
[ "${opt}" = "?" ] && help "Invalid use of script: ${@} "
|
[ "${opt}" = "?" ] && help "Invalid use of script: ${@} "
|
||||||
|
|
||||||
if [ "${opt}" = "-" ]; then #OPTARG is long-option-name or long-option=value
|
if [ "${opt}" = "-" ]; then
|
||||||
if [[ "${OPTARG}" =~ .*=.* ]]; then # --key=value format
|
# OPTARG is long-option-name or long-option=value
|
||||||
|
if [[ "${OPTARG}" =~ .*=.* ]]; then
|
||||||
|
# --key=value format
|
||||||
long=${OPTARG/=*/}
|
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#*=}
|
OPTARG=${OPTARG#*=}
|
||||||
else # --key value format
|
else
|
||||||
eval "opt=\"\${short_opt_${OPTARG}}\"" # Map long name to short version of option
|
# --key value format
|
||||||
eval "OPTARG=\"\${@:OPTIND:\${has_arg_${opt}}}\"" # Only assign OPTARG if option takes an argument
|
# Map long name to short version of option
|
||||||
((OPTIND+=has_arg_${opt})) # shift over the argument if argument is expected
|
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
|
fi
|
||||||
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user