blob: 54559794f7d42ba342672c0ecf8d8540a2b91cee (
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 a0cc3d1f68e23e5e809559d939fcc8717dbbcdcd 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 08/19] 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 4dca315..dc6d4f3 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -140,7 +140,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 6b2210e..9484754 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -562,6 +562,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: *)
--
2.5.0
|