code review 4830042: build: handle spaces in $USER (issue4830042)

22 views
Skip to first unread message

r...@golang.org

unread,
Jul 28, 2011, 12:52:00 PM7/28/11
to golan...@googlegroups.com, golan...@googlegroups.com, re...@codereview.appspotmail.com
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev (cc: golan...@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
build: handle spaces in $USER

Fixes issue 2107.

Please review this at http://codereview.appspot.com/4830042/

Affected files:
M src/cmd/gotry/gotry
M src/quietgcc.bash
M test/run


Index: src/cmd/gotry/gotry
===================================================================
--- a/src/cmd/gotry/gotry
+++ b/src/cmd/gotry/gotry
@@ -111,7 +111,8 @@
functions=$(getFunctions)

# Write file to compile
-rm -f /tmp/$USER.try.go
+file="/tmp/$USER.try"
+rm -f "file.go"
(
cat <<'!'
package main
@@ -159,9 +160,9 @@
func toSlice(a ...interface{}) []interface{} { return a }
!

-)>/tmp/$USER.try.go
+)>"$file.go"

-$GC -o /tmp/$USER.try.$O /tmp/$USER.try.go &&
-$GL -o /tmp/$USER.try /tmp/$USER.try.$O &&
-/tmp/$USER.try "_$@"
-rm -f /tmp/$USER.try /tmp/$USER.try.go /tmp/$USER.try.$O
+$GC -o "$file.$O" "$file.go" &&
+$GL -o "$file" "$file.$O" &&
+"$file" "_$@"
+rm -f "$file" "$file.go" "$file.$O"
Index: src/quietgcc.bash
===================================================================
--- a/src/quietgcc.bash
+++ b/src/quietgcc.bash
@@ -32,13 +32,13 @@
esac

# Run gcc, save error status, redisplay output without noise, exit with
gcc status.
-tmp=${TMPDIR:-/tmp}/quietgcc.$$.$USER.out
+tmp="${TMPDIR:-/tmp}/quietgcc.$$.$USER.out"
$gcc -Wall -Wno-sign-compare -Wno-missing-braces \
-Wno-parentheses -Wno-unknown-pragmas -Wno-switch -Wno-comment \
-Werror \
- "$@" >$tmp 2>&1
+ "$@" >"$tmp" 2>&1
status=$?
-egrep -v "$ignore" $tmp | uniq | tee $tmp.1
+egrep -v "$ignore" "$tmp" | uniq | tee "$tmp.1"

-rm -f $tmp $tmp.1
+rm -f "$tmp" "$tmp.1"
exit $status
Index: test/run
===================================================================
--- a/test/run
+++ b/test/run
@@ -33,9 +33,9 @@

PATH=/bin:/usr/bin:/usr/local/bin:${GOBIN:-$GOROOT/bin}:`pwd`

-RUNFILE=/tmp/gorun-$$-$USER
-TMP1FILE=/tmp/gotest1-$$-$USER
-TMP2FILE=/tmp/gotest2-$$-$USER
+RUNFILE="/tmp/gorun-$$-$USER"
+TMP1FILE="/tmp/gotest1-$$-$USER"
+TMP2FILE="/tmp/gotest2-$$-$USER"

# don't run the machine out of memory: limit individual processes to 4GB.
# on thresher, 3GB suffices to run the tests; with 2GB, peano fails.
@@ -64,20 +64,20 @@
fi
export F=$(basename $i .go)
export D=$dir
- sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >$RUNFILE
- if ! { time -p bash -c "bash $RUNFILE >$TMP1FILE 2>&1" ; } 2>$TMP2FILE
+ sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g'
>"$RUNFILE"
+ if ! { time -p bash -c "bash '$RUNFILE' >'$TMP1FILE' 2>&1" ; }
2>"$TMP2FILE"
then
echo
echo "===========" $i
- cat $TMP1FILE
+ cat "$TMP1FILE"
echo >&2 fail: $i
echo "# $i # fail" >>pass.out
- elif test -s $TMP1FILE
+ elif test -s "$TMP1FILE"
then
echo
echo "===========" $i
- cat $TMP1FILE
- if grep -q '^BUG' $TMP1FILE
+ cat "$TMP1FILE"
+ if grep -q '^BUG' "$TMP1FILE"
then
if [ $dir != bugs ]
then
@@ -93,13 +93,13 @@
else
echo $i >>pass.out
fi
- echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out
+ echo $(awk 'NR==1{print $2}' "$TMP2FILE") $D/$F >>times.out
rm -f $F.$A $A.out
) done
done | # clean up some stack noise
egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' |
sed '/tmp.*Bus error/s/.*Bus/Bus/; /tmp.*Trace.BPT/s/.*Trace/Trace/
- s!'$RUNFILE'!$RUNFILE!g
+ s!'"$RUNFILE"'!$RUNFILE!g
s/^PC=0x[0-9a-f]*/pc: xxx/
s/^pc: 0x[0-9a-f]*/pc: xxx/
s/PC=0x[0-9a-f]*/PC=xxx/
@@ -110,7 +110,7 @@
/Segmentation fault/d
/^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' >
run.out

-rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out
+rm -f "$RUNFILE" "$TMP1FILE" "$TMP2FILE" *.$A *.a $A.out
diffmsg=""
if ! diff $golden run.out
then


r...@golang.org

unread,
Jul 28, 2011, 12:56:20 PM7/28/11
to r...@golang.org, golan...@googlegroups.com, golan...@googlegroups.com, re...@codereview.appspotmail.com
LGTM but have you tested it?

i would like to go back in time, find the person who thought spaces were
a good idea for file names (let alone user names), and stop this
nonsense before it ever spread

http://codereview.appspot.com/4830042/

Russ Cox

unread,
Jul 28, 2011, 1:01:36 PM7/28/11
to r...@golang.org, golan...@googlegroups.com, r...@golang.org, re...@codereview.appspotmail.com
On Thu, Jul 28, 2011 at 12:56, <r...@golang.org> wrote:
> LGTM but have you tested it?

Yes, I did

USER="Broken broken" ./all.bash

and it passed.

r...@golang.org

unread,
Jul 28, 2011, 1:05:02 PM7/28/11
to r...@golang.org, golan...@googlegroups.com, r...@golang.org, re...@codereview.appspotmail.com
*** Submitted as
http://code.google.com/p/go/source/detail?r=2313a84d4d4b ***

build: handle spaces in $USER

Fixes issue 2107.

R=golang-dev, r
CC=golang-dev
http://codereview.appspot.com/4830042


http://codereview.appspot.com/4830042/

Arvindh Rajesh Tamilmani

unread,
Jul 28, 2011, 1:52:22 PM7/28/11
to r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
>  # Write file to compile
> -rm -f /tmp/$USER.try.go
> +file="/tmp/$USER.try"
> +rm -f "file.go"

rm -f "$file.go"

Reply all
Reply to author
Forward
0 new messages