diff --git a/altshfmt b/altshfmt index 686659b..e60fc07 100755 --- a/altshfmt +++ b/altshfmt @@ -174,6 +174,10 @@ altshfmt() { /^[[:space:]]*('"$SHELLSPEC_DSL_ONLINE_DATA"').*/ { next } + /^[[:space:]]*(Parameters:value)([[:space:]].*|$)/ { + # Parameters:value is a standalone construct and does not need braces + next + } /^[[:space:]]*('"$SHELLSPEC_DSL_BEGIN"')([[:space:]].*|$)/ { while(match($0, /.*\\$/)) { getline; print } print "{ # @@altsh@@begin" diff --git a/spec/altshfmt_spec.sh b/spec/altshfmt_spec.sh index c56c2fd..c3613f3 100644 --- a/spec/altshfmt_spec.sh +++ b/spec/altshfmt_spec.sh @@ -201,4 +201,52 @@ Describe "altshfmt" The output should eq "1: arg1 arg2 -l" End End + + # Regression tests + Describe "Parameters:value handling" + Context "when Parameters:value is used in shellspec" + Data + #|#!/bin/bash + #| + #|Parameters:value aarch64 ppc64le s390x x86_64 + #| + #|It 'is simple' + #| When call echo "$1" + #| The output should eq "$1" + #|End + End + + It "formats without syntax errors" + When call altshfmt + The status should be success + The output should include "Parameters:value aarch64 ppc64le s390x x86_64" + End + + It "produces valid shell syntax" + When call bash -c './altshfmt | bash -n' + The status should be success + End + End + + Context "when other Parameters variants are used" + Data + #|#!/bin/bash + #| + #|Parameters:block + #| foo bar + #|End + #| + #|It 'test' + #| echo hello + #|End + End + + It "still formats Parameters:block correctly" + When call altshfmt + The status should be success + The output should include "Parameters:block" + The output should include "foo bar" + End + End + End End