check_GNU_style.sh: Read either from stdin, or from files
authorTom de Vries <tom@codesourcery.com>
Tue, 12 May 2015 16:23:19 +0000 (16:23 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 12 May 2015 16:23:19 +0000 (16:23 +0000)
2015-05-12  Tom de Vries  <tom@codesourcery.com>

* check_GNU_style.sh: Read either from stdin, or from files.

From-SVN: r223086

contrib/ChangeLog
contrib/check_GNU_style.sh

index 605950a1c484856c6eceb7b8a97709dee162939e..da374975417d4f4869a62209e211911326754f76 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-12  Tom de Vries  <tom@codesourcery.com>
+
+       * check_GNU_style.sh: Read either from stdin, or from files.
+
 2015-05-12  Tom de Vries  <tom@codesourcery.com>
 
        * check_GNU_style.sh: Check if files exists.
index 2c4d9e24fe69da83925ded3f1cb8c9d0562f90a1..f00b3d54096cea9b12043e2a4db361d992d83c5a 100755 (executable)
@@ -39,12 +39,22 @@ test $# -eq 0 && usage
 nfiles=$#
 files="$*"
 
-for f in $files; do
-    if [ "$f" != "-" ] && [ ! -f "$f" ]; then
-       echo "error: could not read file: $f"
-       exit 1
-    fi
-done
+stdin=false
+if [ $nfiles -eq 1 ] && [ "$files" = "-" ]; then
+    stdin=true
+else
+    for f in $files; do
+       if [ "$f" = "-" ]; then
+           # Let's keep things simple.  Either we read from stdin, or we read
+           # from files specified on the command line, not both.
+           usage
+       fi
+       if [ ! -f "$f" ]; then
+           echo "error: could not read file: $f"
+           exit 1
+       fi
+    done
+fi
 
 inp=check_GNU_style.inp
 tmp=check_GNU_style.tmp