strongswan: simplify indentation 20725/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Sun, 26 Mar 2023 19:52:55 +0000 (13:52 -0600)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Sun, 26 Mar 2023 19:53:59 +0000 (13:53 -0600)
Allow passing multiple config lines with the same indent level.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/strongswan/files/swanctl.init

index b7af78446a6142a85445493f6ad0b26485539edd..3af15f19e4311639d2c65b5e414eb424f6eeeef6 100644 (file)
@@ -63,9 +63,12 @@ file_reset() {
 
 xappend() {
        local file="$1"
-       shift
+       local indent="$2"
+       shift 2
 
-       echo "$@" >> "$file"
+       for cmd in "$@"; do
+               echo "$indent$cmd" >> "$file"
+       done
 }
 
 swan_reset() {
@@ -77,23 +80,23 @@ swan_xappend() {
 }
 
 swan_xappend0() {
-       swan_xappend "$@"
+       swan_xappend "" "$@"
 }
 
 swan_xappend1() {
-       swan_xappend "  ""$@"
+       swan_xappend "  " "$@"
 }
 
 swan_xappend2() {
-       swan_xappend "    ""$@"
+       swan_xappend "    " "$@"
 }
 
 swan_xappend3() {
-       swan_xappend "      ""$@"
+       swan_xappend "      " "$@"
 }
 
 swan_xappend4() {
-       swan_xappend "        ""$@"
+       swan_xappend "        " "$@"
 }
 
 swanctl_reset() {
@@ -105,23 +108,23 @@ swanctl_xappend() {
 }
 
 swanctl_xappend0() {
-       swanctl_xappend "$@"
+       swanctl_xappend "" "$@"
 }
 
 swanctl_xappend1() {
-       swanctl_xappend "  ""$@"
+       swanctl_xappend "  " "$@"
 }
 
 swanctl_xappend2() {
-       swanctl_xappend "    ""$@"
+       swanctl_xappend "    " "$@"
 }
 
 swanctl_xappend3() {
-       swanctl_xappend "      ""$@"
+       swanctl_xappend "      " "$@"
 }
 
 swanctl_xappend4() {
-       swanctl_xappend "        ""$@"
+       swanctl_xappend "        " "$@"
 }
 
 warning() {
@@ -335,7 +338,7 @@ config_child() {
        [ $ipcomp -eq 1 ] && swanctl_xappend4 "ipcomp = 1"
        [ -n "$interface" ] && swanctl_xappend4 "interface = $interface"
        [ -n "$priority" ] && swanctl_xappend4 "priority = $priority"
-       [ -n "$if_id" ] && { swanctl_xappend4 "if_id_in = $if_id" ; swanctl_xappend4 "if_id_out = $if_id" ; }
+       [ -n "$if_id" ] && swanctl_xappend4 "if_id_in = $if_id" "if_id_out = $if_id"
        [ -n "$startaction" -a "$startaction" != "none" ] && swanctl_xappend4 "start_action = $startaction"
        [ -n "$closeaction" -a "$closeaction" != "none" ] && swanctl_xappend4 "close_action = $closeaction"
        swanctl_xappend4 "esp_proposals = $esp_proposal"