blob: dbb2c898388e4dd0fdbf470845814b49aa4709a2 (
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
58
59
60
61
62
63
64
65
|
From 70d9a1a8b26957ef5772f634346bccfa1dee8811 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Mon, 13 Jul 2015 15:26:04 +0300
Subject: [PATCH 15/15] Shellvars: allow && and || constructs after command
---
lenses/shellvars.aug | 10 +++++++---
lenses/tests/test_shellvars.aug | 8 ++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index 00c6846..0f7c907 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -97,14 +97,17 @@ module Shellvars =
. Util.del_str "return"
. ( Util.del_ws_spc . store Rx.integer )?
- let condition =
+ let cond_actions=
let action (operator:string) (lbl:string) =
[ Sep.opt_space . Util.del_str operator . Sep.opt_space
. label lbl . sto_to_semicol ]
- in let cond (start:string) (end:string) = [ label "type" . store start ]
+ in ( action "&&" "@and" | action "||" "@or" )*
+
+ let condition =
+ let cond (start:string) (end:string) = [ label "type" . store start ]
. Util.del_ws_spc . sto_to_semicol
. Util.del_ws_spc . Util.del_str end
- . ( action "&&" "@and" | action "||" "@or" )*
+ . cond_actions
in Util.indent . label "@condition" . (cond "[" "]" | cond "[[" "]]")
let command =
@@ -114,6 +117,7 @@ module Shellvars =
. [ key key_re . eq . store anyquot . Sep.space . del /(\\\\\n[ \t]*)?/ "" ]*
. store (word - reserved_key - /zzz/)
. [ Sep.space . label "@arg" . sto_to_semicol]?
+ . cond_actions
(************************************************************************
* Group: CONDITIONALS AND LOOPS
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index 4f52205..00f3aad 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -628,6 +628,14 @@ bar" }
{ "@arg" = "arg1 arg2" }
}
+ (* Allow && and || constructs after command *)
+ test Shellvars.lns get "foo bar && baz || quux\n" =
+ { "@command" = "foo"
+ { "@arg" = "bar" }
+ { "@and" = "baz" }
+ { "@or" = "quux" }
+ }
+
(* Local Variables: *)
(* mode: caml *)
(* End: *)
--
2.1.0
|