Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 1/4] test: Add target test-lint-shell-syntax

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:38

Jeff King [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help