From 58bae5374446f76d6fe13892e8185642b3085f7c Mon Sep 17 00:00:00 2001
From: Jonathan Amsterdam <jba@users.noreply.github.com>
Date: Thu, 16 Mar 2017 20:30:42 -0400
Subject: [PATCH] regen.sh: fix two bugs (#20)

1. The protoc include dir of the protobuf repo is the src subdir
   of the repo, not its root.

2. bash allows only one trap command per signal, so arrange to
   delete both temporary repo dirs with one command.
---
 regen.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/regen.sh b/regen.sh
index 76525685..58c900ce 100755
--- a/regen.sh
+++ b/regen.sh
@@ -42,10 +42,15 @@ if [ -z "$root" ]; then
   die "cannot find root of $PKG"
 fi
 
+remove_dirs=
+trap 'rm -rf $remove_dirs' EXIT
+
 if [ -z "$PROTOBUF" ]; then
-  protodir=$(mktemp -d -t regen-cds-proto.XXXXXX)
-  git clone -q $PROTO_REPO $protodir &
-  trap 'rm -rf $protodir' EXIT
+  proto_repo_dir=$(mktemp -d -t regen-cds-proto.XXXXXX)
+  git clone -q $PROTO_REPO $proto_repo_dir &
+  remove_dirs="$proto_repo_dir"
+  # The protoc include directory is actually the "src" directory of the repo.
+  protodir="$proto_repo_dir/src"
 else
   protodir="$PROTOBUF"
 fi
@@ -53,7 +58,7 @@ fi
 if [ -z "$GOOGLEAPIS" ]; then
   apidir=$(mktemp -d -t regen-cds-api.XXXXXX)
   git clone -q $API_REPO $apidir &
-  trap 'rm -rf $apidir' EXIT
+  remove_dirs="$remove_dirs $apidir"
 else
   apidir="$GOOGLEAPIS"
 fi
@@ -70,3 +75,4 @@ echo 1>&2 "Checking that the libraries build..."
 go build -v ./...
 
 echo 1>&2 "All done!"
+
-- 
GitLab