Small bashlib tweaks.
This commit is contained in:
parent
7a97a0b0c8
commit
d472d975ce
@ -582,7 +582,7 @@ csvline() {
|
|||||||
IFS= read -d "$lineDelimiter" -r line || return
|
IFS= read -d "$lineDelimiter" -r line || return
|
||||||
while IFS= read -rn1 c; do
|
while IFS= read -rn1 c; do
|
||||||
case $c in
|
case $c in
|
||||||
\")
|
'"')
|
||||||
(( quoted = !quoted ))
|
(( quoted = !quoted ))
|
||||||
continue ;;
|
continue ;;
|
||||||
$delimiter)
|
$delimiter)
|
||||||
@ -1221,9 +1221,10 @@ options() {
|
|||||||
while getopts "$optstring" arg; do
|
while getopts "$optstring" arg; do
|
||||||
if [[ $arg = h && ! ${options[h]} ]]; then
|
if [[ $arg = h && ! ${options[h]} ]]; then
|
||||||
# Show usage message.
|
# Show usage message.
|
||||||
[[ -t 1 ]]; local fd=$(( $? + 1 )) optarg
|
[[ -t 1 ]] && local fd=1 || local fd=2
|
||||||
|
|
||||||
# Print out the app usage.
|
# Print out the app usage.
|
||||||
|
local optarg
|
||||||
printf " Usage: $reset$bold%s$reset" "${BASH_SOURCE[1]##*/}" >&$fd
|
printf " Usage: $reset$bold%s$reset" "${BASH_SOURCE[1]##*/}" >&$fd
|
||||||
for optchar in "${!options[@]}"; do
|
for optchar in "${!options[@]}"; do
|
||||||
[[ $optchar = *: ]] && optarg=" arg" || optarg=
|
[[ $optchar = *: ]] && optarg=" arg" || optarg=
|
||||||
@ -1274,7 +1275,7 @@ showHelp() {
|
|||||||
(( cols = ${cols:-80} - 10 ))
|
(( cols = ${cols:-80} - 10 ))
|
||||||
|
|
||||||
# Figure out what FD to use for our messages.
|
# Figure out what FD to use for our messages.
|
||||||
[[ -t 1 ]]; local fd=$(( $? + 1 ))
|
[[ -t 1 ]] && local fd=1 || local fd=2
|
||||||
|
|
||||||
# Print out the help header.
|
# Print out the help header.
|
||||||
printf "$reset$bold\n" >&$fd
|
printf "$reset$bold\n" >&$fd
|
||||||
|
Loading…
Reference in New Issue
Block a user