Blame SOURCES/augeas-1.1.0-shellvars-multi-export.patch

c537d4
From c40fc2b24f9f3b104603e3d19ff2b0975b1af9cc Mon Sep 17 00:00:00 2001
c537d4
From: Dominic Cleal <dcleal@redhat.com>
c537d4
Date: Thu, 2 Jan 2014 13:50:41 +0000
c537d4
Subject: [PATCH] Shellvars, Sysconfig: map "bare" export and unset lines using
c537d4
 seq to handle multiple variables
c537d4
c537d4
Fixes RHBZ#1033795
c537d4
c537d4
(cherry picked from commit 15ec3753b0ba82e155426288572f6b92c3cafc59)
c537d4
c537d4
Conflicts:
c537d4
	NEWS
c537d4
	lenses/tests/test_shellvars.aug
c537d4
---
c537d4
 lenses/shellvars.aug            |  6 ++++--
c537d4
 lenses/tests/test_shellvars.aug | 21 ++++++++++++++++-----
c537d4
 lenses/tests/test_sysconfig.aug |  8 +++++---
c537d4
 3 files changed, 25 insertions(+), 10 deletions(-)
c537d4
c537d4
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
c537d4
index a88ad83..da19379 100644
c537d4
--- a/lenses/shellvars.aug
c537d4
+++ b/lenses/shellvars.aug
c537d4
@@ -63,8 +63,10 @@ module Shellvars =
c537d4
            . eq . (simple_value | array) . comment_or_eol ]
c537d4
 
c537d4
   let var_action (name:string) =
c537d4
-    [ Util.indent . xchgs name ("@" . name) . Util.del_ws_spc
c537d4
-    . store (key_re | matching_re) . comment_or_eol ]
c537d4
+    Util.indent . del name name . Util.del_ws_spc .
c537d4
+      [ label ("@" . name) . counter "var_action"
c537d4
+        . Build.opt_list [ seq "var_action" . store (key_re | matching_re) ] Util.del_ws_spc
c537d4
+        . comment_or_eol ]
c537d4
 
c537d4
   let unset = var_action "unset"
c537d4
   let bare_export = var_action "export"
c537d4
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
c537d4
index 9aea433..79a5a4e 100644
c537d4
--- a/lenses/tests/test_shellvars.aug
c537d4
+++ b/lenses/tests/test_shellvars.aug
c537d4
@@ -30,7 +30,8 @@ unset ONBOOT    #   We do not want this var
c537d4
     { "#comment" = "DHCP_HOSTNAME=host.example.com" }
c537d4
     { "NETMASK" = "255.255.255.0" }
c537d4
     { "NETWORK" = "172.31.0.0" }
c537d4
-    { "@unset"   = "ONBOOT"
c537d4
+    { "@unset"
c537d4
+        { "1" = "ONBOOT" }
c537d4
         { "#comment" = "We do not want this var" } }
c537d4
 
c537d4
   test lns put eth_static after
c537d4
@@ -147,7 +148,8 @@ unset ONBOOT    #   We do not want this var
c537d4
 
c537d4
   (* Bug 109: allow a bare export *)
c537d4
   test lns get "export FOO\n" =
c537d4
-  { "@export" = "FOO" }
c537d4
+  { "@export"
c537d4
+    { "1" = "FOO" } }
c537d4
 
c537d4
   (* Bug 73: allow ulimit builtin *)
c537d4
   test lns get "ulimit -c unlimited\n" =
c537d4
@@ -259,7 +261,8 @@ esac\n" =
c537d4
     { "@case_entry" = "/tmp/file2"
c537d4
       { ".source" = "/tmp/file2" } }
c537d4
     { "@case_entry" = "*"
c537d4
-      { "@unset" = "f" } } }
c537d4
+      { "@unset"
c537d4
+        { "1" = "f" } } } }
c537d4
 
c537d4
   (* Select *)
c537d4
   test lns get "select i in a b c; do . /tmp/file$i
c537d4
@@ -346,7 +349,8 @@ esac\n" =
c537d4
     { "#comment" = "comment before 2" }
c537d4
     { "@case_entry" = "*"
c537d4
       { "#comment" = "comment in 2" }
c537d4
-      { "@unset" = "f" } }
c537d4
+      { "@unset"
c537d4
+        { "1" = "f" } } }
c537d4
     { "#comment" = "comment after" } }
c537d4
 
c537d4
   (* Empty case *)
c537d4
@@ -397,7 +401,8 @@ esac\n" =
c537d4
 
c537d4
   (* unset can be used on wildcard variables *)
c537d4
   test Shellvars.lns get "unset ${!LC_*}\n" =
c537d4
-  { "@unset" = "${!LC_*}" }
c537d4
+  { "@unset"
c537d4
+    { "1" = "${!LC_*}" } }
c537d4
 
c537d4
   (* Empty comment before entries *)
c537d4
   test Shellvars.lns get "# \nfoo=bar\n" =
c537d4
@@ -435,6 +440,12 @@ esac\n" =
c537d4
     { "#comment" = "foo" }
c537d4
     { "foo" = "bar" }
c537d4
 
c537d4
+  (* Export of multiple variables, RHBZ#1033795 *)
c537d4
+  test lns get "export TestVar1 TestVar2\n" =
c537d4
+    { "@export"
c537d4
+      { "1" = "TestVar1" }
c537d4
+      { "2" = "TestVar2" } }
c537d4
+
c537d4
 (* Local Variables: *)
c537d4
 (* mode: caml       *)
c537d4
 (* End:             *)
c537d4
diff --git a/lenses/tests/test_sysconfig.aug b/lenses/tests/test_sysconfig.aug
c537d4
index 539ad99..fa1601a 100644
c537d4
--- a/lenses/tests/test_sysconfig.aug
c537d4
+++ b/lenses/tests/test_sysconfig.aug
c537d4
@@ -30,8 +30,9 @@ unset ONBOOT    #   We do not want this var
c537d4
     { "#comment" = "DHCP_HOSTNAME=host.example.com" }
c537d4
     { "NETMASK" = "255.255.255.0" }
c537d4
     { "NETWORK" = "172.31.0.0" }
c537d4
-    { "@unset"   = "ONBOOT"
c537d4
-        { "#comment" = "We do not want this var" } }
c537d4
+    { "@unset"
c537d4
+      { "1" = "ONBOOT" }
c537d4
+      { "#comment" = "We do not want this var" } }
c537d4
 
c537d4
   test lns put eth_static after
c537d4
       set "BOOTPROTO" "dhcp" ;
c537d4
@@ -124,7 +125,8 @@ unset ONBOOT    #   We do not want this var
c537d4
 
c537d4
   (* Bug 109: allow a bare export *)
c537d4
   test lns get "export FOO\n" =
c537d4
-  { "@export" = "FOO" }
c537d4
+  { "@export"
c537d4
+    { "1" = "FOO" } }
c537d4
 
c537d4
   (* Check we put quotes in when changes require them *)
c537d4
   test lns put "var=\"v\"\n" after rm "/foo" =
c537d4
-- 
c537d4
1.8.4.2
c537d4