summaryrefslogtreecommitdiffstats
path: root/main/augeas/0006-Shellvars-case-support-quotes-and-spaces-in-pattern-.patch
blob: c02c1bc8b40c9f721f381c77a0ed9968bf9e1c77 (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
From d66b7bcff272868ae367bcd66e78e07263c1748d Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Mon, 8 Dec 2014 15:17:46 +0200
Subject: [PATCH 06/10] Shellvars: case: support quotes and spaces in pattern
 lists

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

diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index 3671186..0c25ff9 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -130,7 +130,7 @@ module Shellvars =
 
   let case (entry:lens) (entry_noeol:lens) =
     let case_entry = [ label "@case_entry"
-                       . Util.indent . store /[^ \t\n\)]+/
+                       . Util.indent . sto_to_semicol
                        . Util.del_str ")" . eol
                        . ( entry+ | entry_noeol )?
                        . Util.indent . Util.del_str ";;" . eol ] in
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index 8d8f34d..ee23698 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -506,6 +506,24 @@ fi\n" =
   test Shellvars.lns get "for x in \"$@\"; do y=$x; done\n" =
   { "@for" = "x in \"$@\"" { "y" = "$x" } }
 
+  (* case: support quotes and spaces in pattern lists *)
+  test lns get "case $ARG in
+        \"foo bar\")
+           Foo=0
+           ;;
+        baz | quux)
+           Foo=1
+           ;;
+esac\n" =
+    { "@case" = "$ARG"
+      { "@case_entry" = "\"foo bar\""
+        { "Foo" = "0" }
+      }
+      { "@case_entry" = "baz | quux"
+        { "Foo" = "1" }
+      }
+    }
+
 (* Local Variables: *)
 (* mode: caml       *)
 (* End:             *)
-- 
1.8.3.1