Make separate_list handle enclosures in a more general way

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@2437 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2005-07-31 17:12:04 +00:00
parent 0a03598d11
commit 54a5a111a6

View File

@ -165,6 +165,9 @@ separate_list() {
local firstpart local firstpart
local lastpart local lastpart
local enclosure local enclosure
case "$list" in
*,|,*|*,,*|*[[:space:]]*)
# #
# There's been whining about us not catching embedded white space in # There's been whining about us not catching embedded white space in
# comma-separated lists. This is an attempt to snag some of the cases. # comma-separated lists. This is an attempt to snag some of the cases.
@ -173,8 +176,6 @@ separate_list() {
# either 'startup_error' or 'fatal_error' depending on the command and # either 'startup_error' or 'fatal_error' depending on the command and
# command phase # command phase
# #
case "$list" in
*,|,*|*,,*|*[[:space:]]*)
[ -n "$terminator" ] && \ [ -n "$terminator" ] && \
$terminator "Invalid comma-separated list \"$@\"" $terminator "Invalid comma-separated list \"$@\""
echo "Warning -- invalid comma-separated list \"$@\"" >&2 echo "Warning -- invalid comma-separated list \"$@\"" >&2
@ -186,16 +187,30 @@ separate_list() {
# #
firstpart=${list%%\[*} firstpart=${list%%\[*}
lastpart=${list#*\[} lastpart=${list#*\[}
enclosure=${lastpart%\]*} enclosure=${lastpart%%\]*}
lastpart=${lastpart#*\]} lastpart=${lastpart#*\]}
case $lastpart in case $lastpart in
\,*) \,*)
case $firstpart in
*\,)
echo "$(separate_list ${firstpart%,}) [$enclosure] $(separate_list ${lastpart#,})"
;;
*)
echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})" echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})"
;; ;;
esac
;;
*)
case $firstpart in
*\,)
echo "$(separate_list ${firstpart%,}) [$enclosure]$(separate_list $lastpart)"
;;
*) *)
echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)" echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)"
;; ;;
esac esac
;;
esac
return return
;; ;;
esac esac