gollvm: set the shell variable correctly in CMakeLists.txt

Currently CMakeLists.txt in gollvm sets a work shell from SHELL environment variable. If there is no variable named SHELL in the environment, the configuration of gollvm will fail. This patch fix this issue by setting the default shell to /bin/bash.

Fixes golang/go#40631

Change-Id: Ifcd41611549134bbe5ce11373627b33eba6e75c1
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/247198
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/cmake/modules/AutoGenGo.cmake b/cmake/modules/AutoGenGo.cmake
index 7c59578..a17b62a 100644
--- a/cmake/modules/AutoGenGo.cmake
+++ b/cmake/modules/AutoGenGo.cmake
@@ -434,7 +434,11 @@
   get_filename_component(outfile "${outpath}" NAME)
   get_filename_component(outdir "${outpath}" DIRECTORY)
   set(tmpfile "${outdir}/tmp-${outfile}")
-  set(shell $ENV{SHELL})
+  if(DEFINED ENV{SHELL})
+    set(shell $ENV{SHELL})
+  else()
+    set(shell "/bin/bash")
+  endif()
 
   # Create a rule that runs the script into a temporary file.
   if( NOT ARG_CAPTURE )
diff --git a/cmake/modules/GoVars.cmake b/cmake/modules/GoVars.cmake
index 4579e70..ec6f6b2 100644
--- a/cmake/modules/GoVars.cmake
+++ b/cmake/modules/GoVars.cmake
@@ -32,9 +32,10 @@
 endif()
 
 # We need a working shell. 
-set(shell $ENV{SHELL})
-if(shell STREQUAL "")
-set(shell "/bin/bash")
+if(DEFINED ENV{SHELL})
+  set(shell $ENV{SHELL})
+else()
+  set(shell "/bin/bash")
 endif()
 execute_process(COMMAND "${shell}" "-c" "echo foo" OUTPUT_VARIABLE echofoo)
 if(echofoo STREQUAL "")