[TopGit PATCH/RFC fixup] suppress "cannot overwrite existing file" error
- From
Jonathan Nieder <jrnieder@uchicago.edu>
- Date
- Aug 12, 2008, 18:21 UTC
- Message-ID
- <Pine.GSO.4.62.0808121317110.18832@harper.uchicago.edu>
- In-Reply-To
- <Pine.GSO.4.62.0808121309000.18832@harper.uchicago.edu>
We had been using sh -C ": >filename" to atomically create a file, but this has the unfortunate side effect of producing an error message if the file already exists. So suppress the error.
Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu> --- Here's a fix to a mistake in the patch I just sent. If the patch was meant for application, I would be suggesting squashing this change in. Sorry for the noise.
tg.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tg.sh b/tg.sh index c31256f..65375d6 100644 --- a/tg.sh +++ b/tg.sh @@ -85,14 +85,14 @@ branch_contains() # nonzero status on failure temp_filename() { - set -C && umask 077 + umask 077 prefix=$1 i=0 suffix=$(awk 'BEGIN { srand(); rand(); print int(rand()*99999) }') while test $i -lt 256 do tmp=$prefix$suffix - : >"$tmp" && break + sh -C -c ': >"$tmp"' 2>/dev/null && break i=$(($i+1)) suffix=$(($suffix+1)) done
-- 1.6.0.rc2.531.g79a96