Re: [PATCH 1/4] test: Add target test-lint-shell-syntax
Jeff King <peff@peff.net> writes:
Show 29 quoted lines
> So taking all of that, a more idiomatic perl script would look something
> like:
>
> my $exit_code;
> sub err {
> my $msg = shift;
> print "$ARGV:$.: error: $msg: $_\n";
> $exit_code = 1;
> }
>
> while (<>) {
> chomp;
> if (/^\s*sed\s+-i/) {
> err('sed -i is not portable');
> }
> # ...and so on
>
> # this resets our $. for each file
> close ARGV if eof;
> }
> exit $exit_code;
>
> I'd personally probably write the conditions like:
>
> /^\s*sed\s+-i/ and err('sed -i is not portable');
>
> to make the structure of the program (i.e., a list of conditions to
> complain about) clear, but I know not everybody agrees with such a terse
> style.Thanks for a nicely-done review.