mirror of
https://github.com/drwetter/testssl.sh.git
synced 2026-07-15 03:27:38 +02:00
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) .
This commit is contained in:
Executable
+29
@@ -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
|
||||||
|
|
||||||
Reference in New Issue
Block a user