Skip to content

Commit

Permalink
setlocalversion: Use "grep -q" instead of piping output to "read dummy"
Browse files Browse the repository at this point in the history
In some circumstances (eg when running a build in an emacs shell
buffer), I get a spew of messages like

    grep: writing output: Broken pipe

from setlocalversion, because the "read" subshell apparently exits as
soon as it reads one line and gives EPIPE to grep.  It's not clear to
me why this way of writing the check was used instead of just using
grep -q to suppress output, but unless there is some deep reason I
don't know, this way looks cleaner to me anyway, and gets rid of the
ugly message spew.

(I double checked at http://pubs.opengroup.org/onlinepubs/009604499/utilities/grep.html
and "grep -q" is specified in POSIX / SuS, so hopefully even people
cross-compiling the kernel on some bizarre host OS can't complain
about this change)

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
  • Loading branch information
Roland Dreier authored and Michal Marek committed Mar 26, 2012
1 parent 9aaf440 commit 7f3bd6c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions scripts/setlocalversion
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ scm_version()
[ -w . ] && git update-index --refresh --unmerged > /dev/null

# Check for uncommitted changes
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
| read dummy; then
if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
printf '%s' -dirty
fi

Expand Down

0 comments on commit 7f3bd6c

Please sign in to comment.