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,16 +165,17 @@ separate_list() {
local firstpart local firstpart
local lastpart local lastpart
local enclosure local enclosure
#
# 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.
#
# The 'terminator' function will be set by the 'firewall' script to
# either 'startup_error' or 'fatal_error' depending on the command and
# command phase
#
case "$list" in case "$list" in
*,|,*|*,,*|*[[:space:]]*) *,|,*|*,,*|*[[:space:]]*)
#
# 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.
#
# The 'terminator' function will be set by the 'firewall' script to
# either 'startup_error' or 'fatal_error' depending on the command and
# command phase
#
[ -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,15 +187,29 @@ separate_list() {
# #
firstpart=${list%%\[*} firstpart=${list%%\[*}
lastpart=${list#*\[} lastpart=${list#*\[}
enclosure=${lastpart%\]*} enclosure=${lastpart%%\]*}
lastpart=${lastpart#*\]} lastpart=${lastpart#*\]}
case $lastpart in case $lastpart in
\,*) \,*)
echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})" case $firstpart in
*\,)
echo "$(separate_list ${firstpart%,}) [$enclosure] $(separate_list ${lastpart#,})"
;;
*)
echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})"
;;
esac
;; ;;
*) *)
echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)" case $firstpart in
;; *\,)
echo "$(separate_list ${firstpart%,}) [$enclosure]$(separate_list $lastpart)"
;;
*)
echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)"
;;
esac
;;
esac esac
return return
;; ;;