$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'"'
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'"'
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"
// add goroot to the end of the libdir list.
libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
+ // Unix doesn't like it when we write to a running (or, sometimes,
+ // recently run) binary, so remove the output file before writing it.
+ // On Windows 7, remove() can force the following create() to fail.
+#ifndef _WIN32
remove(outfile);
+#endif
cout = create(outfile, 1, 0775);
if(cout < 0) {
diag("cannot create %s", outfile);