Subject: [PATCH 2/4] checkbashisms: do not unconditionally swallow stdin

From: Raphael Geissert <[email-masked]>
Date: Thu, 19 Apr 2012 23:07:59 -0500

---
 scripts/checkbashisms.pl |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 2c995cd..bc89d3b 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -50,16 +50,6 @@ my ($opt_echo, $opt_force, $opt_extra, $opt_posix);
 my ($opt_help, $opt_version);
 my @filenames;
 
-# Detect if STDIN is a pipe
-if (-p STDIN or -f STDIN) {
-    my ($tmp_fh, $tmp_filename) = tempfile("chkbashisms_tmp.XXXX", TMPDIR => 1, UNLINK => 1);
-    while (my $line = <STDIN>) {
-        print $tmp_fh $line;
-    }
-    close($tmp_fh);
-    push(@ARGV, $tmp_filename);
-}
-
 ##
 ## handle command-line options
 ##
@@ -79,6 +69,16 @@ if ($opt_version) { print $version; exit 0; }
 
 $opt_echo = 1 if $opt_posix;
 
+# Detect if STDIN is a pipe
+if (scalar(@ARGV) == 0 && (-p STDIN or -f STDIN)) {
+    my ($tmp_fh, $tmp_filename) = tempfile("chkbashisms_tmp.XXXX", TMPDIR => 1, UNLINK => 1);
+    while (my $line = <STDIN>) {
+        print $tmp_fh $line;
+    }
+    close($tmp_fh);
+    push(@ARGV, $tmp_filename);
+}
+
 my $status = 0;
 my $makefile = 0;
 my (%bashisms, %string_bashisms, %singlequote_bashisms);
-- 
1.7.9.1