aboutsummaryrefslogtreecommitdiffstats
path: root/main/augeas/0005-Shellvars-allow-quotes-in-loop-conditions.patch
blob: d4dcdb9a5177465226c6539f5dc7b189d13ba9b1 (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
From 1e842317de344335cf6f0b947156b401df1daae4 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Mon, 8 Dec 2014 14:28:16 +0200
Subject: [PATCH 05/10] Shellvars: allow quotes in loop conditions

---
 lenses/shellvars.aug            | 8 +-------
 lenses/tests/test_shellvars.aug | 4 ++++
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index e318328..3671186 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -45,12 +45,6 @@ module Shellvars =
   let anyquot = (char|dquot|squot|dollar_assign|dollar_arithm)+ | bquot | dbquot
   let sto_to_semicol = store (anyquot . (Rx.space . anyquot)*)
 
-  let sto_to_semicol_quot =
-       let no_semicol_re = /[^"'#;\n]/
-    in let no_semicol_spc_re = /[^"'#; \t\n]/
-    in let multi_chars = no_semicol_spc_re . (no_semicol_re|anyquot)+ . no_semicol_spc_re
-    in store (no_semicol_spc_re | multi_chars)
-
   (* Array values of the form '(val1 val2 val3)'. We do not handle empty *)
   (* arrays here because of typechecking headaches. Instead, they are    *)
   (* treated as a simple value                                           *)
@@ -108,7 +102,7 @@ module Shellvars =
   let generic_cond_start (start_kw:string) (lbl:string)
                          (then_kw:string) (contents:lens) =
       keyword_label start_kw lbl . Sep.space
-      . sto_to_semicol_quot . semicol_eol
+      . sto_to_semicol . semicol_eol
       . keyword then_kw . eol
       . contents
 
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index 90e529b..8d8f34d 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -502,6 +502,10 @@ fi\n" =
   test Shellvars.lns get "for x in foo \\\nbar\\\nbaz; do y=$x; done\n" =
   { "@for" = "x in foo \\\nbar\\\nbaz" { "y" = "$x" } }
 
+  (* Allow quotes in loop conditions *)
+  test Shellvars.lns get "for x in \"$@\"; do y=$x; done\n" =
+  { "@for" = "x in \"$@\"" { "y" = "$x" } }
+
 (* Local Variables: *)
 (* mode: caml       *)
 (* End:             *)
-- 
1.8.3.1