From 0c16ebd6b9af1af62849d16e2c6c43c27036529b Mon Sep 17 00:00:00 2001 From: Dirk Date: Fri, 10 Jul 2026 19:33:08 +0200 Subject: [PATCH] Small check for semantic check Staring with a simple pattern for checking for non-variables at left hand side like [[ LHS == $value ]]. The file is supposed be amended in the future. This fixes #3074 . Upon commit it fails first as there are two instances which will be detected (one is deliberate but will be changed too) . --- t/03_syntax_check.t | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 t/03_syntax_check.t diff --git a/t/03_syntax_check.t b/t/03_syntax_check.t new file mode 100755 index 0000000..07dca9c --- /dev/null +++ b/t/03_syntax_check.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl + +# Basics: are there semantic errors which are easy to spot? + +use strict; +use Test::More; + +my $tests = 0; +my $prg="testssl.sh"; +# Patterns used to trigger an error: + +#1 +printf "\n%s\n", "Testing for missing vars at left hand side in double square brackets ..."; + +# I know this isn't nice but perl doesn't seem for this so great either +my @matches = `grep -n '\\[\\[ [[:alpha:]]' $prg`; +is(scalar(@matches), 0, "Checking bad '[[ LHS' patterns") + or diag(@matches); +$tests++; +i + +# more would go here + +printf "\n"; +done_testing($tests); + + +# vim:ts=5:sw=5:expandtab +