ld: Fixes issue 1899 ("cannot create 8.out.exe")

http://code.google.com/p/go/issues/detail?id=1899

R=rsc, alex.brainman, bsiegert, hectorchu, bradfitz
CC=golang-dev
https://golang.org/cl/4978047
diff --git a/doc/progs/run b/doc/progs/run
index 9d56049..7a6a603 100755
--- a/doc/progs/run
+++ b/doc/progs/run
@@ -42,9 +42,13 @@
 	$GC $i
 done
 
+# Write to temporary file to avoid mingw bash bug.
+TMPFILE="/tmp/gotest3"
+
 function testit {
 	$LD $1.$O
-	x=$(echo $(./$O.out $2 2>&1))  # extra echo canonicalizes
+	./$O.out $2 2>&1 >"$TMPFILE" || true
+	x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
 	if [ "$x" != "$3" ]
 	then
 		echo $1 failed: '"'$x'"' is not '"'$3'"'
@@ -53,7 +57,8 @@
 
 function testitpipe {
 	$LD $1.$O
-	x=$(echo $(./$O.out | $2 2>&1))  # extra echo canonicalizes
+	./$O.out | $2 2>&1 >"$TMPFILE" || true
+	x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
 	if [ "$x" != "$3" ]
 	then
 		echo $1 failed: '"'$x'"' is not '"'$3'"'
@@ -88,4 +93,4 @@
 testit eff_bytesize "" "1.00YB 9.09TB"
 testit eff_sequence "" "[-1 2 6 16 44]"
 
-rm -f $O.out *.$O
+rm -f $O.out $O.out.exe *.$O "$TMPFILE"