#!/bin/bash # collect arguments, # prepend them with command name and current directory filename="/tmp/x-$$.txt" args='dir=' args+=`pwd` args+='\nprogram=%name%' for arg in "$@" do args+='\narg=' args+=$arg done # add env vars (spaces added not send empty lines) args+='\nenv.SVN_EDITOR=' args+=$SVN_EDITOR args+='\nenv.SVN_MERGE=' args+=$SVN_MERGE args+='\nenv.SVNTEST_EDITOR_FUNC=' args+=$SVNTEST_EDITOR_FUNC args+='\nenv.SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_SLEEP_FOR_TIMESTAMPS=' args+=$SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_SLEEP_FOR_TIMESTAMPS args+='\nenv.SVN_CURRENT_TEST=' args+=$SVN_CURRENT_TEST # add empty line args+=' \n\n' printf "%b" "$args" > "$filename" # check input if [ ! -t 0 ] then tee -a $filename <&0 > /dev/null fi printf "%b" "\0" >> "$filename" # now send all that to the server # use netcat when available nc=`which nc` if [ -x $nc ] then data=`$nc localhost %port% < $filename` else exec 3<>/dev/tcp/localhost/%port% echo -e -n "$args">&3 data=$(cat <&3) fi rm "$filename" # process data with simple regexps ERR_START="svnkit_err" RC_START="svnkit_rc" data1=${data%%$ERR_START*$RC_START*} data2=${data:${#data1}} rc=${data2##$ERR_START*$RC_START} data2=${data2%$RC_START[[:digit:]]} data2=${data2:${#ERR_START}} # we receive escaped string echo -en "$data1" echo -en "$data2">&2 exit $rc