public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, 3/5] check_GNU_style.sh: Read either from stdin, or from files
@ 2015-05-12  7:29 Tom de Vries
  2015-05-12 15:03 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2015-05-12  7:29 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

Hi,

this patch makes sure we either handle:
...
$ cat temp.patch | ./check_GNU_style.sh -
...
or
...
$ ./check_GNU_style.sh temp.patch
...
but not:
...
$ cat temp.patch | ./check_GNU_style.sh - temp2.patch
...

OK for trunk?

Thanks,
- Tom


[-- Attachment #2: 0003-check_GNU_style.sh-Read-either-from-stdin-or-from-fi.patch --]
[-- Type: text/x-patch, Size: 1109 bytes --]

[PATCH 3/5] check_GNU_style.sh: Read either from stdin, or from files

2015-05-11  Tom de Vries  <tom@codesourcery.com>

	* check_GNU_style.sh: Read either from stdin, or from files.
---
 contrib/check_GNU_style.sh | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 2c4d9e2..f00b3d5 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -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
-- 
1.9.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, 3/5] check_GNU_style.sh: Read either from stdin, or from files
  2015-05-12  7:29 [PATCH, 3/5] check_GNU_style.sh: Read either from stdin, or from files Tom de Vries
@ 2015-05-12 15:03 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2015-05-12 15:03 UTC (permalink / raw)
  To: Tom de Vries, GCC Patches

On 05/12/2015 01:29 AM, Tom de Vries wrote:
> Hi,
>
> this patch makes sure we either handle:
> ...
> $ cat temp.patch | ./check_GNU_style.sh -
> ...
> or
> ...
> $ ./check_GNU_style.sh temp.patch
> ...
> but not:
> ...
> $ cat temp.patch | ./check_GNU_style.sh - temp2.patch
> ...
>
> OK for trunk?
>
> Thanks,
> - Tom
>
>
> 0003-check_GNU_style.sh-Read-either-from-stdin-or-from-fi.patch
>
>
> [PATCH 3/5] check_GNU_style.sh: Read either from stdin, or from files
>
> 2015-05-11  Tom de Vries<tom@codesourcery.com>
>
> 	* check_GNU_style.sh: Read either from stdin, or from files.
OK.
jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-12 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12  7:29 [PATCH, 3/5] check_GNU_style.sh: Read either from stdin, or from files Tom de Vries
2015-05-12 15:03 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).