Add missing >&2s on echos.
This commit is contained in:
parent
e59eb107e3
commit
67028c4fae
1 changed files with 11 additions and 17 deletions
18
parse_ini
18
parse_ini
|
|
@ -111,11 +111,10 @@ parser_getopts() {
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
# Stop option processing.
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
--*|-*)
|
--*|-*)
|
||||||
echo "${0##*/}: invalid option: $1"
|
echo "${0##*/}: invalid option: $1" >&2
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
@ -198,7 +197,7 @@ parser_help() {
|
||||||
and section name is kept as set. With this option all items are converted
|
and section name is kept as set. With this option all items are converted
|
||||||
to upper case. The case of the propertie's keys/values is not affected.
|
to upper case. The case of the propertie's keys/values is not affected.
|
||||||
Option processing ceases with the first non-option argument, or "--".
|
Option processing ceases with the first non-option argument, or "--".
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_version() {
|
parser_version() {
|
||||||
|
|
@ -380,7 +379,7 @@ parse_ini() {
|
||||||
# Strip the quotes as they're not needed.
|
# Strip the quotes as they're not needed.
|
||||||
LINE="${LINE:1:-1}"
|
LINE="${LINE:1:-1}"
|
||||||
else
|
else
|
||||||
echo "${0##*/}: line $LINENUMBER: unmatched quotes - ignoring property"
|
echo "${0##*/}: line $LINENUMBER: unmatched quotes - ignoring property" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -406,7 +405,7 @@ parse_ini() {
|
||||||
# printf "%s%s%s+=([\"%s\"]=\"%s\")\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$BOOL_VALUE"
|
# printf "%s%s%s+=([\"%s\"]=\"%s\")\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$BOOL_VALUE"
|
||||||
printf "%s%s%s[\"%s\"]=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$BOOL_VALUE"
|
printf "%s%s%s[\"%s\"]=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$BOOL_VALUE"
|
||||||
else
|
else
|
||||||
echo "${0##*/}: line $LINENUMBER: key without a value - ignoring property"
|
echo "${0##*/}: line $LINENUMBER: key without a value - ignoring property" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
elif ((IGNORE_SECTION == 0)); then # Process the property definition as a key/value pair.
|
elif ((IGNORE_SECTION == 0)); then # Process the property definition as a key/value pair.
|
||||||
|
|
@ -429,23 +428,18 @@ parse_ini() {
|
||||||
# Strip the quotes as they're not needed.
|
# Strip the quotes as they're not needed.
|
||||||
VALUE="${VALUE:1:-1}"
|
VALUE="${VALUE:1:-1}"
|
||||||
else
|
else
|
||||||
echo "${0##*/}: line $LINENUMBER: unmatched quotes - ignoring property"
|
echo "${0##*/}: line $LINENUMBER: unmatched quotes - ignoring property" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the associative array element definition.
|
# Output the associative array element definition.
|
||||||
# FIXME: If doing validation only, don't output declaration here.
|
# FIXME: If doing validation only, don't output declaration here.
|
||||||
# FIXME: Need to make sure multiple keys with the same name add to the element, not replace it.
|
|
||||||
# FIXME: Have an option to have repeat sections/properties over-write previous ones rather than append.
|
# FIXME: Have an option to have repeat sections/properties over-write previous ones rather than append.
|
||||||
# FIXME: Need to handle bash <4.4 (by CLI option?): declare -n foo="$prefix$delim$section"; $prefix$delim$section["$key"]="${foo["$key"]}$value"
|
|
||||||
# For bash 4.4+.
|
|
||||||
# printf "%s%s%s+=([\"%s\"]+=\"%s\")\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "$VALUE"
|
|
||||||
# For bash 4.0+
|
|
||||||
printf "%s%s%s[\"%s\"]+=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "$VALUE"
|
printf "%s%s%s[\"%s\"]+=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "$VALUE"
|
||||||
else
|
else
|
||||||
# FIXME: Make this debug output only.
|
# FIXME: Make this debug output only.
|
||||||
echo "Skipping line $LINENUMBER"
|
echo "Skipping line $LINENUMBER" >&2
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue