From d66b7bcff272868ae367bcd66e78e07263c1748d Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 8 Dec 2014 15:17:46 +0200 Subject: [PATCH 06/10] Shellvars: case: support quotes and spaces in pattern lists --- lenses/shellvars.aug | 2 +- lenses/tests/test_shellvars.aug | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug index 3671186..0c25ff9 100644 --- a/lenses/shellvars.aug +++ b/lenses/shellvars.aug @@ -130,7 +130,7 @@ module Shellvars = let case (entry:lens) (entry_noeol:lens) = let case_entry = [ label "@case_entry" - . Util.indent . store /[^ \t\n\)]+/ + . Util.indent . sto_to_semicol . Util.del_str ")" . eol . ( entry+ | entry_noeol )? . Util.indent . Util.del_str ";;" . eol ] in diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug index 8d8f34d..ee23698 100644 --- a/lenses/tests/test_shellvars.aug +++ b/lenses/tests/test_shellvars.aug @@ -506,6 +506,24 @@ fi\n" = test Shellvars.lns get "for x in \"$@\"; do y=$x; done\n" = { "@for" = "x in \"$@\"" { "y" = "$x" } } + (* case: support quotes and spaces in pattern lists *) + test lns get "case $ARG in + \"foo bar\") + Foo=0 + ;; + baz | quux) + Foo=1 + ;; +esac\n" = + { "@case" = "$ARG" + { "@case_entry" = "\"foo bar\"" + { "Foo" = "0" } + } + { "@case_entry" = "baz | quux" + { "Foo" = "1" } + } + } + (* Local Variables: *) (* mode: caml *) (* End: *) -- 1.8.3.1