blob: 420d29fa2fc4168329df5caddd146fabf1a774e9 (
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 9764767e2c633bcedf91d3d7a9ec2542e4658ff0 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 5/5] 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 a50c0f6..b683cc0 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -145,7 +145,7 @@ module Shellvars =
let case_entry = [ label "@case_entry"
. Util.indent . store /[^ \t\n\)]+/
. 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 5b9fdba..0ff1b1a 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -478,6 +478,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
|