On 2010-07-30 16:52:23 +0200, Vincent Lefevre wrote:
> Since http://subversion.tigris.org/issues/show_bug.cgi?id=3014
> ("svn log | head" should not print "Write error: Broken pipe")
> isn't fixed yet, I've eventually written a simple wrapper. See
> attachment. It's not perfect, but better than nothing.
> Note: for those who use localized messages, the script needs to
> be modified accordingly.

Here's a new version (attached). The previous script had a freezing
problem when a background process was started via $SVN_SSH. The
method used to solve this problem also allowed me to solve the
exit status problem.

Vincent Lefèvre <vinc...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

# svn wrapper to avoid "svn: Write error: Broken pipe" error messages
# when piping the svn output to some command.
# Note: the svnwrapper:term trick prevents this script from freezing
# if svn starts a background process via $SVN_SSH (e.g. ssh -fMN ...
# for connection sharing) that still has its stderr connected to the
# pipe after svn terminates. It also allows the script to propagate
# the exit status of svn when there is no broken pipe.
# Script written by Vincent Lefevre <vinc...@vinc17.net> in July 2010,
# released in the public domain.

  unset brpipe status
  while read err
    case "$err" in
        break ;;
      *Write\ error:\ Broken\ pipe) brpipe=1 ;;
      *) printf "%s\n" "$err" ;;
  test -z "$brpipe" || kill -PIPE $$
  exit $status

  { svn "$@" 2>&1 >&3 3>&-; echo "svnwrapper:term:$?"; } | filter >&2 3>&-
} 3>&1

# $Id: svnwrapper 38299 2010-07-30 17:30:17Z vinc17/ypig $

Reply via email to