check_GNU_style.sh: Put stdin into temp file
2015-05-12 Tom de Vries <tom@codesourcery.com> * check_GNU_style.sh: Put stdin into a temp file. From-SVN: r223087
This commit is contained in:
parent
7f167be6ac
commit
a22e33d04a
2 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
2015-05-12 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
* check_GNU_style.sh: Put stdin into a temp file.
|
||||
|
||||
2015-05-12 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
* check_GNU_style.sh: Read either from stdin, or from files.
|
||||
|
|
|
@ -40,8 +40,15 @@ nfiles=$#
|
|||
files="$*"
|
||||
|
||||
stdin=false
|
||||
stdin_tmp=""
|
||||
if [ $nfiles -eq 1 ] && [ "$files" = "-" ]; then
|
||||
stdin=true
|
||||
|
||||
# By putting stdin into a temp file, we can handle it just like any other
|
||||
# file. F.i., we can cat it twice, which we can't do with stdin.
|
||||
stdin_tmp=check_GNU_style.stdin
|
||||
cat - > $stdin_tmp
|
||||
files=$stdin_tmp
|
||||
else
|
||||
for f in $files; do
|
||||
if [ "$f" = "-" ]; then
|
||||
|
@ -60,8 +67,8 @@ inp=check_GNU_style.inp
|
|||
tmp=check_GNU_style.tmp
|
||||
|
||||
# Remove $tmp on exit and various signals.
|
||||
trap "rm -f $inp $tmp" 0
|
||||
trap "rm -f $inp $tmp ; exit 1" 1 2 3 5 9 13 15
|
||||
trap "rm -f $inp $tmp $stdin_tmp" 0
|
||||
trap "rm -f $inp $tmp $stdin_tmp; exit 1" 1 2 3 5 9 13 15
|
||||
|
||||
if [ $nfiles -eq 1 ]; then
|
||||
# There's no need for the file prefix if we're dealing only with one file.
|
||||
|
|
Loading…
Add table
Reference in a new issue