Skip to content

Commit 083aef0

Browse files
committed
Set set +e in generate.sh (go generate) to output correct information
While playing with go in tensorflow, the `go generate` will not output correct information about missing protoc even though generate.sh contains the following: ``` PATH_PROTOC=$(which protoc) if [ ! -x "${PATH_PROTOC}" ] then echo "Protocol buffer compiler protoc not found in PATH or in ${PROTOC}" echo "Perhaps build it using:" echo "bazel build --config opt @protobuf//:protoc" exit 1 fi PROTOC=$PATH_PROTOC ``` Instread, a non-informative error is displayed: ``` root@99829f070f46:/go/src/github.com/tensorflow/tensorflow# go generate github.com/tensorflow/tensorflow/tensorflow/go/op ../genop/main.go:15: running "sh": exit status 1 tensorflow/go/op/generate.go:15: running "go": exit status 1 root@99829f070f46:/go/src/github.com/tensorflow/tensorflow# ``` The reason is that `set -e` is at the beginning of the script and it exit immediately at `PATH_PROTOC=$(which protoc)`. This fix sets `set +e` before `PATH_PROTOC=$(which protoc)` and restores `set -e` back, so that information about missing protoc outputed. Below is the new output: ``` root@99829f070f46:/go/src/github.com/tensorflow/tensorflow# go generate github.com/tensorflow/tensorflow/tensorflow/go/op Protocol buffer compiler protoc not found in PATH or in /go/src/github.com/tensorflow/tensorflow/bazel-out/host/bin/external/protobuf/protoc Perhaps build it using: bazel build --config opt @protobuf//:protoc ../genop/main.go:15: running "sh": exit status 1 tensorflow/go/op/generate.go:15: running "go": exit status 1 root@99829f070f46:/go/src/github.com/tensorflow/tensorflow# ``` Signed-off-by: Yong Tang <[email protected]>
1 parent 43c2d68 commit 083aef0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tensorflow/go/genop/generate.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PROTOC="${TF_DIR}/bazel-out/host/bin/external/protobuf/protoc"
2525

2626
if [ ! -x "${PROTOC}" ]
2727
then
28+
set +e
2829
PATH_PROTOC=$(which protoc)
2930
if [ ! -x "${PATH_PROTOC}" ]
3031
then
@@ -34,6 +35,7 @@ then
3435
exit 1
3536
fi
3637
PROTOC=$PATH_PROTOC
38+
set -e
3739
fi
3840

3941
# Ensure that protoc-gen-go is available in $PATH

0 commit comments

Comments
 (0)