From e26cd076e322b636438e0a9570434a8135af32a4 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 9 Oct 2024 20:02:17 -0400 Subject: sbolint: tighten up chown . checking (still not happy with it). --- sbolint | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sbolint b/sbolint index 7d0ad72..9d71eb6 100755 --- a/sbolint +++ b/sbolint @@ -1465,8 +1465,26 @@ sub check_script { $makepkg = $lineno; } elsif(/^\s*?CWD=/) { log_warning("$file:$lineno: lone CWD= assignment is redundant in 15.0 template"); - } elsif(/^\s*?chown\s+[^#;]*\S+\.\S+/) { - log_warning("$file:$lineno: chown should use : instead of . for user:group separator"); + } elsif(/^\s*?chown\s/) { + # explanation in english: get rid of any comment portion of the command, + # then if we (a) have no : character, and (b) have what looks like + # user.group or $user.$group, complain. + # if (a) is true but (b) isn't, that probably means the user:group is + # given together in one variable, and we can't really check that. + # that, or there's no user/group at all (e.g. chown's --reference + # option). + my $chown = $_; + $chown =~ s/#.*//; + if(($chown !~ /:/) && + ($chown =~ / + (?:\b|\$) # word boundary or $ (in case it's a variable) + \w[\w\d]+ # assume user or var starts with letter or _, and >=2 chars long + \. # a literal dot + [\w\$][\w\d]+ # user or var again + /x)) + { + log_warning("$file:$lineno: chown should use : instead of . for user:group separator"); + } } if(/^[^#]*/) { -- cgit v1.2.3