aboutsummaryrefslogtreecommitdiffstats
path: root/main/augeas/0009-Shellvars-case-support-on-same-line-with-multiple-co.patch
blob: bc13be9b4425c761263657712327bb7b039f571c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 26253c2b82f489c03330b022a05ab89bf9a28312 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Thu, 4 Dec 2014 21:51:03 +0200
Subject: [PATCH 09/10] Shellvars: case: support ;; on same line with multiple
 commands

---
 lenses/shellvars.aug            |  2 +-
 lenses/tests/test_shellvars.aug | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index 3b98c23..9cef3fd 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -137,7 +137,7 @@ module Shellvars =
     let case_entry = [ label "@case_entry"
                        . Util.indent . sto_to_semicol
                        . Util.del_str ")" . eol
-                       . ( entry+ | entry_noeol )?
+                       . entry* . entry_noeol?
                        . Util.indent . Util.del_str ";;" . eol ] in
       [ keyword_label "case" "@case" . Sep.space
         . store (char+ | ("\"" . char+ . "\""))
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index c1892cd..f38fd30 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -479,6 +479,25 @@ esac\n" =
       { "@case_entry" = "1"
         { "TestVar" = "\"test1\"" } } }
 
+  (* case: support ;; on the same line with multiple commands *)
+  test lns get "case $ARG in
+        0) Foo=0; Bar=1;;
+        1)
+	   Foo=2
+	   Bar=3; Baz=4;;
+esac\n" =
+    { "@case" = "$ARG"
+      { "@case_entry" = "0"
+        { "Foo" = "0" }
+        { "Bar" = "1" }
+      }
+      { "@case_entry" = "1"
+        { "Foo" = "2" }
+        { "Bar" = "3" }
+        { "Baz" = "4" }
+      }
+    }
+
 (* Test: Shellvars.lns
      Support `##` bashism in conditions (GH issue #118) *)
 test Shellvars.lns get "if [ \"${APACHE_CONFDIR##/etc/apache2-}\" != \"${APACHE_CONFDIR}\" ] ; then
-- 
1.8.3.1