From 26253c2b82f489c03330b022a05ab89bf9a28312 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 4 Dec 2014 21:51:03 +0200 Subject: [PATCH 09/10] 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 3b98c23..9cef3fd 100644 --- a/lenses/shellvars.aug +++ b/lenses/shellvars.aug @@ -137,7 +137,7 @@ module Shellvars = let case_entry = [ label "@case_entry" . Util.indent . sto_to_semicol . 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 c1892cd..f38fd30 100644 --- a/lenses/tests/test_shellvars.aug +++ b/lenses/tests/test_shellvars.aug @@ -479,6 +479,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