From: Junio C Hamano Date: Wed, 02 Jan 2013 16:28:13 GMT Subject: Re: [PATCH 1/4] test: Add target test-lint-shell-syntax Message-ID: <7vmwwr4kiq.fsf@alter.siamese.dyndns.org> In-Reply-To: <20130102094635.GD9328@sigill.intra.peff.net> Jeff King writes: > 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.