#!/bin/sh # 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 in July 2010, # released in the public domain. filter() { unset brpipe status IFS="" while read err do case "$err" in svnwrapper:term:*) status=${err#svnwrapper:term:} break ;; *Broken\ pipe) brpipe=1 ;; *) printf "%s\n" "$err" ;; esac done test -z "$brpipe" || kill -PIPE $$ exit $status } { { svn "$@" 2>&1 >&3 3>&-; echo "svnwrapper:term:$?"; } | filter >&2 3>&- } 3>&1 # $Id: svnwrapper.sh 38471 2010-08-06 11:37:20Z vinc17/ypig $