mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-13 01:30:58 +01:00
Fix regression introduced in 5749d9e
This commit is contained in:
parent
d38d5b518e
commit
469a6fc65f
11
lib/opt.sh
11
lib/opt.sh
@ -7,11 +7,12 @@
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
PROGRAM="$(basename "${BASH_SOURCE[0]}")"
|
PROGRAM="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
# Sets the internal _ARGV and _ARGV_INDEX variables used when
|
# Sets the internal _ARGV, _ARGV_INDEX, and _ARGV_LAST variables used when
|
||||||
# parsing options with the shiftopt and shiftval functions.
|
# parsing options with the shiftopt and shiftval functions.
|
||||||
setargs() {
|
setargs() {
|
||||||
_ARGV=("$@")
|
_ARGV=("$@")
|
||||||
_ARGV_INDEX="$((${#_ARGV[@]} - 1))"
|
_ARGV_LAST="$((${#_ARGV[@]} - 1))"
|
||||||
|
_ARGV_INDEX=0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Gets the next option passed to the script.
|
# Gets the next option passed to the script.
|
||||||
@ -30,7 +31,7 @@ setargs() {
|
|||||||
# done
|
# done
|
||||||
shiftopt() {
|
shiftopt() {
|
||||||
# Read the top of _ARGV.
|
# Read the top of _ARGV.
|
||||||
[[ "$_ARGV_INDEX" -lt 0 ]] && return 1
|
[[ "$_ARGV_INDEX" -gt "$_ARGV_LAST" ]] && return 1
|
||||||
OPT="${_ARGV[$_ARGV_INDEX]}"
|
OPT="${_ARGV[$_ARGV_INDEX]}"
|
||||||
unset OPT_VAL
|
unset OPT_VAL
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ shiftopt() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Pop array.
|
# Pop array.
|
||||||
((_ARGV_INDEX--))
|
((_ARGV_INDEX++))
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ shiftval() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
OPT_VAL="${_ARGV[$_ARGV_INDEX]}"
|
OPT_VAL="${_ARGV[$_ARGV_INDEX]}"
|
||||||
((_ARGV_INDEX--))
|
((_ARGV_INDEX++))
|
||||||
|
|
||||||
# Error if no value is provided.
|
# Error if no value is provided.
|
||||||
if [[ "$OPT_VAL" =~ -.* ]]; then
|
if [[ "$OPT_VAL" =~ -.* ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user