blob: e85f60fa2434bf6c41da475a1831f181f1482efc (
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 25007fa071f37998016b4f197bf6509e43174517 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 07/15] 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 227e2a3..4dca315 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -48,12 +48,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 *)
@@ -118,7 +112,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 bf92735..6b2210e 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -558,6 +558,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: *)
--
2.1.0
|