From faa0993e738e5ec6d59696e9fd3b96ab513e0e8d Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 8 Dec 2014 14:28:16 +0200 Subject: [PATCH 07/19] 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.5.0