From 9764767e2c633bcedf91d3d7a9ec2542e4658ff0 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 4 Dec 2014 21:51:03 +0200 Subject: [PATCH 5/5] Shellvars: case: support ;; on same line with multiple commands --- lenses/shellvars.aug | 2 +- lenses/tests/test_shellvars.aug | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug index a50c0f6..b683cc0 100644 --- a/lenses/shellvars.aug +++ b/lenses/shellvars.aug @@ -145,7 +145,7 @@ module Shellvars = let case_entry = [ label "@case_entry" . Util.indent . store /[^ \t\n\)]+/ . Util.del_str ")" . eol - . ( entry+ | entry_noeol )? + . entry* . entry_noeol? . Util.indent . Util.del_str ";;" . eol ] in [ keyword_label "case" "@case" . Sep.space . store (char+ | ("\"" . char+ . "\"")) diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug index 5b9fdba..0ff1b1a 100644 --- a/lenses/tests/test_shellvars.aug +++ b/lenses/tests/test_shellvars.aug @@ -478,6 +478,25 @@ esac\n" = { "@case_entry" = "1" { "TestVar" = "\"test1\"" } } } + (* case: support ;; on the same line with multiple commands *) + test lns get "case $ARG in + 0) Foo=0; Bar=1;; + 1) + Foo=2 + Bar=3; Baz=4;; +esac\n" = + { "@case" = "$ARG" + { "@case_entry" = "0" + { "Foo" = "0" } + { "Bar" = "1" } + } + { "@case_entry" = "1" + { "Foo" = "2" } + { "Bar" = "3" } + { "Baz" = "4" } + } + } + (* Test: Shellvars.lns Support `##` bashism in conditions (GH issue #118) *) test Shellvars.lns get "if [ \"${APACHE_CONFDIR##/etc/apache2-}\" != \"${APACHE_CONFDIR}\" ] ; then -- 1.8.3.1