diff --git a/util/lint/lint-stable-027-maintainers-syntax b/util/lint/lint-stable-027-maintainers-syntax index 85245d1247..d0753d7316 100755 --- a/util/lint/lint-stable-027-maintainers-syntax +++ b/util/lint/lint-stable-027-maintainers-syntax @@ -1,21 +1,34 @@ #!/usr/bin/env perl # SPDX-License-Identifier: GPL-2.0-or-later # -# DESCR: Check that path patterns in MAINTAINERS have trailing slash +# DESCR: Check the syntax of the MAINTAINERS file use strict; use warnings; +sub check_path { + my ($path) = @_; + + if ( ! -e $path ) { + print "MAINTAINERS:$. No such file or directory exists "; + print "`$path`\n"; + } +} + open( my $file, "<", "MAINTAINERS" ) or die "Error: could not open file 'MAINTAINERS'\n"; while ( my $line = <$file> ) { - if ( $line =~ /^[FX]:\s+([^\s]*[^*\/\s])\s+$/ ) { # path patterns not ending with / or * + if ( $line =~ /^[FX]:\s+([^\s]*)\s+$/ ) { my $path = $1; - if ( -d $path ) { + # Match path patterns not ending with '/' or '*'. This cannot be done + # in check_path(), as it only works on pre-globbed paths. + if ( $path =~ /[^*\/\s]$/ && -d $path ) { print "MAINTAINERS:$. missing trailing slash for directory match "; print "`$path`\n"; } + + check_path($_) foreach ( glob $path ); } }