golang: Quote variables passed to the shell
authorJeffery To <jeffery.to@gmail.com>
Fri, 28 Aug 2020 18:07:34 +0000 (02:07 +0800)
committerJeffery To <jeffery.to@gmail.com>
Tue, 6 Oct 2020 08:34:40 +0000 (16:34 +0800)
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/golang/golang-compiler.mk
lang/golang/golang-package.mk
lang/golang/golang/Makefile

index cf350d82c89c8f6f7c2513219c568dd9f6ad5945..e8b4b915632cb81c53cd96138e93f76526de20e2 100644 (file)
@@ -24,8 +24,8 @@ endef
 # $(4) additional environment variables (optional)
 define GoCompiler/Default/Make
        ( \
-               cd $(1)/src ; \
-               $(if $(2),GOROOT_FINAL=$(2)/lib/go-$(3)) \
+               cd "$(1)/src" ; \
+               $(if $(2),GOROOT_FINAL="$(2)/lib/go-$(3)") \
                $(4) \
                $(BASH) make.bash --no-banner ; \
        )
@@ -34,8 +34,8 @@ endef
 # $(1) destination prefix
 # $(2) go version id
 define GoCompiler/Default/Install/make-dirs
-       $(INSTALL_DIR) $(1)/lib/go-$(2)
-       $(INSTALL_DIR) $(1)/share/go-$(2)
+       $(INSTALL_DIR) "$(1)/lib/go-$(2)"
+       $(INSTALL_DIR) "$(1)/share/go-$(2)"
 endef
 
 # $(1) source go root
@@ -43,8 +43,8 @@ endef
 # $(3) go version id
 # $(4) file/directory name
 define GoCompiler/Default/Install/install-share-data
-       $(CP) $(1)/$(4) $(2)/share/go-$(3)/
-       $(LN) ../../share/go-$(3)/$(4) $(2)/lib/go-$(3)/
+       $(CP) "$(1)/$(4)" "$(2)/share/go-$(3)/"
+       $(LN) "../../share/go-$(3)/$(4)" "$(2)/lib/go-$(3)/"
 endef
 
 # $(1) source go root
@@ -57,35 +57,35 @@ define GoCompiler/Default/Install/Bin
 
        $(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),api)
 
-       $(INSTALL_DATA) -p $(1)/VERSION $(2)/lib/go-$(3)/
+       $(INSTALL_DATA) -p "$(1)/VERSION" "$(2)/lib/go-$(3)/"
 
        for file in AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE PATENTS README.md SECURITY.md; do \
-               if [ -f $(1)/$$$$file ]; then \
-                       $(INSTALL_DATA) -p $(1)/$$$$file $(2)/share/go-$(3)/ ; \
+               if [ -f "$(1)/$$$$file" ]; then \
+                       $(INSTALL_DATA) -p "$(1)/$$$$file" "$(2)/share/go-$(3)/" ; \
                fi ; \
        done
 
-       $(INSTALL_DIR) $(2)/lib/go-$(3)/bin
+       $(INSTALL_DIR) "$(2)/lib/go-$(3)/bin"
 
   ifeq ($(4),$(GO_HOST_OS_ARCH))
-       $(INSTALL_BIN) -p $(1)/bin/* $(2)/lib/go-$(3)/bin/
+       $(INSTALL_BIN) -p "$(1)/bin"/* "$(2)/lib/go-$(3)/bin/"
   else
-       $(INSTALL_BIN) -p $(1)/bin/$(4)/* $(2)/lib/go-$(3)/bin/
+       $(INSTALL_BIN) -p "$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/"
   endif
 
-       $(INSTALL_DIR) $(2)/lib/go-$(3)/pkg
-       $(CP) $(1)/pkg/$(4)$(if $(5),_$(5)) $(2)/lib/go-$(3)/pkg/
+       $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg"
+       $(CP) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/"
 
-       $(INSTALL_DIR) $(2)/lib/go-$(3)/pkg/tool/$(4)
-       $(INSTALL_BIN) -p $(1)/pkg/tool/$(4)/* $(2)/lib/go-$(3)/pkg/tool/$(4)/
+       $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg/tool/$(4)"
+       $(INSTALL_BIN) -p "$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/"
 endef
 
 # $(1) destination prefix
 # $(2) go version id
 define GoCompiler/Default/Install/BinLinks
-       $(INSTALL_DIR) $(1)/bin
-       $(LN) ../lib/go-$(2)/bin/go $(1)/bin/go
-       $(LN) ../lib/go-$(2)/bin/gofmt $(1)/bin/gofmt
+       $(INSTALL_DIR) "$(1)/bin"
+       $(LN) "../lib/go-$(2)/bin/go" "$(1)/bin/go"
+       $(LN) "../lib/go-$(2)/bin/gofmt" "$(1)/bin/gofmt"
 endef
 
 # $(1) source go root
@@ -111,29 +111,29 @@ define GoCompiler/Default/Install/Src
        $(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),test)
 
        $(FIND) \
-               $(2)/share/go-$(3)/src/ \
-               \! -type d -a \( -name '*.bat' -o -name '*.rc' \) \
+               "$(2)/share/go-$(3)/src/" \
+               \! -type d -a \( -name "*.bat" -o -name "*.rc" \) \
                -delete
 
-       if [ -d $(1)/pkg/include ]; then \
-               $(INSTALL_DIR) $(2)/lib/go-$(3)/pkg ; \
-               $(INSTALL_DIR) $(2)/share/go-$(3)/pkg ; \
-               $(CP) $(1)/pkg/include $(2)/share/go-$(3)/pkg/ ; \
-               $(LN) ../../../share/go-$(3)/pkg/include $(2)/lib/go-$(3)/pkg/ ; \
+       if [ -d "$(1)/pkg/include" ]; then \
+               $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg" ; \
+               $(INSTALL_DIR) "$(2)/share/go-$(3)/pkg" ; \
+               $(CP) "$(1)/pkg/include" "$(2)/share/go-$(3)/pkg/" ; \
+               $(LN) "../../../share/go-$(3)/pkg/include" "$(2)/lib/go-$(3)/pkg/" ; \
        fi
 endef
 
 # $(1) destination prefix
 # $(2) go version id
 define GoCompiler/Default/Uninstall
-       rm -rf $(1)/lib/go-$(2)
-       rm -rf $(1)/share/go-$(2)
+       rm -rf "$(1)/lib/go-$(2)"
+       rm -rf "$(1)/share/go-$(2)"
 endef
 
 # $(1) destination prefix
 define GoCompiler/Default/Uninstall/BinLinks
-       rm -f $(1)/bin/go
-       rm -f $(1)/bin/gofmt
+       rm -f "$(1)/bin/go"
+       rm -f "$(1)/bin/gofmt"
 endef
 
 
index 46b484b4dabe6eaee1bac13bc59214c7288bf8e1..b3d01857f481b1358c53115bd24d0b5f657b900c 100644 (file)
@@ -165,24 +165,24 @@ define GoPackage/GoSubMenu
 endef
 
 GO_PKG_TARGET_VARS= \
-       GOOS=$(GO_OS) \
-       GOARCH=$(GO_ARCH) \
-       GO386=$(GO_386) \
-       GOARM=$(GO_ARM) \
-       GOMIPS=$(GO_MIPS) \
-       GOMIPS64=$(GO_MIPS64) \
+       GOOS="$(GO_OS)" \
+       GOARCH="$(GO_ARCH)" \
+       GO386="$(GO_386)" \
+       GOARM="$(GO_ARM)" \
+       GOMIPS="$(GO_MIPS)" \
+       GOMIPS64="$(GO_MIPS64)" \
        CGO_ENABLED=1 \
-       CC=$(TARGET_CC) \
-       CXX=$(TARGET_CXX) \
+       CC="$(TARGET_CC)" \
+       CXX="$(TARGET_CXX)" \
        CGO_CFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CFLAGS))" \
        CGO_CPPFLAGS="$(TARGET_CPPFLAGS)" \
        CGO_CXXFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CXXFLAGS))" \
        CGO_LDFLAGS="$(TARGET_LDFLAGS)"
 
 GO_PKG_BUILD_VARS= \
-       GOPATH=$(GO_PKG_BUILD_DIR) \
-       GOCACHE=$(GO_BUILD_CACHE_DIR) \
-       GOMODCACHE=$(GO_MOD_CACHE_DIR) \
+       GOPATH="$(GO_PKG_BUILD_DIR)" \
+       GOCACHE="$(GO_BUILD_CACHE_DIR)" \
+       GOMODCACHE="$(GO_MOD_CACHE_DIR)" \
        GOENV=off
 
 GO_PKG_DEFAULT_VARS= \
@@ -213,77 +213,77 @@ GO_PKG_INSTALL_ARGS= \
        $(if $(GO_PKG_TAGS),-tags "$(GO_PKG_TAGS)")
 
 # false if directory does not exist
-GoPackage/is_dir_not_empty=$$$$($(FIND) $(1) -maxdepth 0 -type d \! -empty 2>/dev/null)
+GoPackage/is_dir_not_empty=$$$$($(FIND) "$(1)" -maxdepth 0 -type d \! -empty 2>/dev/null)
 
 GoPackage/has_binaries=$(call GoPackage/is_dir_not_empty,$(GO_PKG_BUILD_BIN_DIR))
 
 define GoPackage/Build/Configure
        ( \
-               cd $(PKG_BUILD_DIR) ; \
+               cd "$(PKG_BUILD_DIR)" ; \
                mkdir -p \
-                       $(GO_PKG_BUILD_DIR)/bin $(GO_PKG_BUILD_DIR)/src \
-                       $(GO_BUILD_CACHE_DIR) $(GO_MOD_CACHE_DIR) ; \
+                       "$(GO_PKG_BUILD_DIR)/bin" "$(GO_PKG_BUILD_DIR)/src" \
+                       "$(GO_BUILD_CACHE_DIR)" "$(GO_MOD_CACHE_DIR)" ; \
                \
-               files=$$$$($(FIND) ./ \
-                       -type d -a \( -path './.git' -o -path './$(GO_PKG_WORK_DIR_NAME)' \) -prune -o \
+               files="$$$$($(FIND) ./ \
+                       -type d -a \( -path "./.git" -o -path "./$(GO_PKG_WORK_DIR_NAME)" \) -prune -o \
                        \! -type d -print | \
-                       sed 's|^\./||') ; \
+                       sed 's|^\./||')" ; \
                \
                if [ "$(strip $(GO_PKG_INSTALL_ALL))" != 1 ]; then \
-                       code=$$$$(echo "$$$$files" | grep '\.\(c\|cc\|cpp\|go\|h\|hh\|hpp\|proto\|s\)$$$$') ; \
-                       testdata=$$$$(echo "$$$$files" | grep '\(^\|/\)testdata/') ; \
-                       gomod=$$$$(echo "$$$$files" | grep '\(^\|/\)go\.\(mod\|sum\)$$$$') ; \
+                       code="$$$$(echo "$$$$files" | grep '\.\(c\|cc\|cpp\|go\|h\|hh\|hpp\|proto\|s\)$$$$')" ; \
+                       testdata="$$$$(echo "$$$$files" | grep '\(^\|/\)testdata/')" ; \
+                       gomod="$$$$(echo "$$$$files" | grep '\(^\|/\)go\.\(mod\|sum\)$$$$')" ; \
                        \
                        for pattern in $(GO_PKG_INSTALL_EXTRA); do \
-                               extra=$$$$(echo "$$$$extra"; echo "$$$$files" | grep "$$$$pattern") ; \
+                               extra="$$$$(echo "$$$$extra"; echo "$$$$files" | grep "$$$$pattern")" ; \
                        done ; \
                        \
-                       files=$$$$(echo "$$$$code"; echo "$$$$testdata"; echo "$$$$gomod"; echo "$$$$extra") ; \
-                       files=$$$$(echo "$$$$files" | grep -v '^[[:space:]]*$$$$' | sort -u) ; \
+                       files="$$$$(echo "$$$$code"; echo "$$$$testdata"; echo "$$$$gomod"; echo "$$$$extra")" ; \
+                       files="$$$$(echo "$$$$files" | grep -v '^[[:space:]]*$$$$' | sort -u)" ; \
                fi ; \
                \
                IFS=$$$$'\n' ; \
                \
                echo "Copying files from $(PKG_BUILD_DIR) into $(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))" ; \
                for file in $$$$files; do \
-                       echo $$$$file ; \
-                       dest=$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))/$$$$file ; \
-                       mkdir -p $$$$(dirname $$$$dest) ; \
-                       $(CP) $$$$file $$$$dest ; \
+                       echo "$$$$file" ; \
+                       dest="$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))/$$$$file" ; \
+                       mkdir -p "$$$$(dirname "$$$$dest")" ; \
+                       $(CP) "$$$$file" "$$$$dest" ; \
                done ; \
                echo ; \
                \
                link_contents() { \
-                       local src=$$$$1 ; \
-                       local dest=$$$$2 ; \
+                       local src="$$$$1" ; \
+                       local dest="$$$$2" ; \
                        local dirs dir base ; \
                        \
-                       if [ -n "$$$$($(FIND) $$$$src -mindepth 1 -maxdepth 1 -name '*.go' \! -type d)" ]; then \
+                       if [ -n "$$$$($(FIND) "$$$$src" -mindepth 1 -maxdepth 1 -name "*.go" \! -type d)" ]; then \
                                echo "$$$$src is already a Go library" ; \
                                return 1 ; \
                        fi ; \
                        \
-                       dirs=$$$$($(FIND) $$$$src -mindepth 1 -maxdepth 1 -type d) ; \
+                       dirs="$$$$($(FIND) "$$$$src" -mindepth 1 -maxdepth 1 -type d)" ; \
                        for dir in $$$$dirs; do \
-                               base=$$$$(basename $$$$dir) ; \
-                               if [ -d $$$$dest/$$$$base ]; then \
-                                       case $$$$dir in \
+                               base="$$$$(basename "$$$$dir")" ; \
+                               if [ -d "$$$$dest/$$$$base" ]; then \
+                                       case "$$$$dir" in \
                                        *$(GO_PKG_PATH)/src/$(strip $(GO_PKG))) \
                                                echo "$(strip $(GO_PKG)) is already installed. Please check for circular dependencies." ;; \
                                        *) \
-                                               link_contents $$$$src/$$$$base $$$$dest/$$$$base ;; \
+                                               link_contents "$$$$src/$$$$base" "$$$$dest/$$$$base" ;; \
                                        esac ; \
                                else \
                                        echo "...$$$${src#$(GO_PKG_BUILD_DEPENDS_SRC)}/$$$$base" ; \
-                                       $(LN) $$$$src/$$$$base $$$$dest/$$$$base ; \
+                                       $(LN) "$$$$src/$$$$base" "$$$$dest/$$$$base" ; \
                                fi ; \
                        done ; \
                } ; \
                \
                if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \
-                       if [ -d $(GO_PKG_BUILD_DEPENDS_SRC) ]; then \
+                       if [ -d "$(GO_PKG_BUILD_DEPENDS_SRC)" ]; then \
                                echo "Symlinking directories from $(GO_PKG_BUILD_DEPENDS_SRC) into $(GO_PKG_BUILD_DIR)/src" ; \
-                               link_contents $(GO_PKG_BUILD_DEPENDS_SRC) $(GO_PKG_BUILD_DIR)/src ; \
+                               link_contents "$(GO_PKG_BUILD_DEPENDS_SRC)" "$(GO_PKG_BUILD_DIR)/src" ; \
                        else \
                                echo "$(GO_PKG_BUILD_DEPENDS_SRC) does not exist, skipping symlinks" ; \
                        fi ; \
@@ -297,16 +297,16 @@ endef
 # $(1) additional arguments for go command line (optional)
 define GoPackage/Build/Compile
        ( \
-               cd $(GO_PKG_BUILD_DIR) ; \
+               cd "$(GO_PKG_BUILD_DIR)" ; \
                export $(GO_PKG_VARS) ; \
                if [ -f "$(PKG_BUILD_DIR)/go.mod" ] ; then \
                        modargs="$(GO_MOD_ARGS)" ; \
                fi ; \
                \
                echo "Finding targets" ; \
-               targets=$$$$(go list $$$$modargs $(GO_PKG_BUILD_PKG)) ; \
+               targets="$$$$(go list $$$$modargs $(GO_PKG_BUILD_PKG))" ; \
                for pattern in $(GO_PKG_EXCLUDES); do \
-                       targets=$$$$(echo "$$$$targets" | grep -v "$$$$pattern") ; \
+                       targets="$$$$(echo "$$$$targets" | grep -v "$$$$pattern")" ; \
                done ; \
                echo ; \
                \
@@ -319,7 +319,7 @@ define GoPackage/Build/Compile
                if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \
                        echo "Building targets" ; \
                        go install $(GO_PKG_INSTALL_ARGS) $$$$modargs $(1) $$$$targets ; \
-                       retval=$$$$? ; \
+                       retval="$$$$?" ; \
                        echo ; \
                        \
                        if [ "$$$$retval" -eq 0 ] && [ -z "$(call GoPackage/has_binaries)" ]; then \
@@ -331,7 +331,7 @@ define GoPackage/Build/Compile
                                $(call Go/CacheCleanup) ; \
                        fi ; \
                fi ; \
-               exit $$$$retval ; \
+               exit "$$$$retval" ; \
        )
 endef
 
@@ -341,15 +341,15 @@ endef
 
 define GoPackage/Package/Install/Bin
        if [ -n "$(call GoPackage/has_binaries)" ]; then \
-               $(INSTALL_DIR) $(1)/usr/bin ; \
-               $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/* $(1)/usr/bin/ ; \
+               $(INSTALL_DIR) "$(1)/usr/bin" ; \
+               $(INSTALL_BIN) "$(GO_PKG_BUILD_BIN_DIR)"/* "$(1)/usr/bin/" ; \
        fi
 endef
 
 define GoPackage/Package/Install/Src
-       dir=$$$$(dirname $(GO_PKG)) ; \
-       $(INSTALL_DIR) $(1)$(GO_PKG_PATH)/src/$$$$dir ; \
-       $(CP) $(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG)) $(1)$(GO_PKG_PATH)/src/$$$$dir/
+       dir="$$$$(dirname "$(GO_PKG)")" ; \
+       $(INSTALL_DIR) "$(1)$(GO_PKG_PATH)/src/$$$$dir" ; \
+       $(CP) "$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))" "$(1)$(GO_PKG_PATH)/src/$$$$dir/"
 endef
 
 define GoPackage/Package/Install
index 6990c249e2271e083c0f8aaf9c0a0031a5208842..a5474753b12067d3848f23ac55ebd6685b6d0b5a 100644 (file)
@@ -88,9 +88,9 @@ include $(INCLUDE_DIR)/package.mk
 include ../golang-compiler.mk
 include ../golang-package.mk
 
-PKG_UNPACK:=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-HOST_UNPACK:=$(HOST_TAR) -C $(HOST_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-BOOTSTRAP_UNPACK:=$(HOST_TAR) -C $(BOOTSTRAP_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(BOOTSTRAP_SOURCE)
+PKG_UNPACK:=$(HOST_TAR) -C "$(PKG_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
+HOST_UNPACK:=$(HOST_TAR) -C "$(HOST_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
+BOOTSTRAP_UNPACK:=$(HOST_TAR) -C "$(BOOTSTRAP_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(BOOTSTRAP_SOURCE)"
 
 # don't strip ELF executables in test data
 RSTRIP:=:
@@ -174,7 +174,7 @@ ifeq ($(BOOTSTRAP_ROOT_DIR),)
   $(eval $(call Download,golang-bootstrap))
 
   define Bootstrap/Prepare
-       mkdir -p $(BOOTSTRAP_BUILD_DIR)
+       mkdir -p "$(BOOTSTRAP_BUILD_DIR)"
        $(BOOTSTRAP_UNPACK)
   endef
   Hooks/HostPrepare/Post+=Bootstrap/Prepare
@@ -195,23 +195,23 @@ endif
 $(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
 
 HOST_GO_VARS= \
-       GOCACHE=$(GO_BUILD_CACHE_DIR) \
+       GOCACHE="$(GO_BUILD_CACHE_DIR)" \
        GOENV=off \
-       CC=$(HOSTCC_NOCACHE) \
-       CXX=$(HOSTCXX_NOCACHE)
+       CC="$(HOSTCC_NOCACHE)" \
+       CXX="$(HOSTCXX_NOCACHE)"
 
 define Host/Compile
        $(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
        $(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
 
-       mkdir -p $(GO_BUILD_CACHE_DIR)
+       mkdir -p "$(GO_BUILD_CACHE_DIR)"
 
        $(call GoCompiler/Bootstrap/Make, \
                $(HOST_GO_VARS) \
        )
 
        $(call GoCompiler/Host/Make, \
-               GOROOT_BOOTSTRAP=$(BOOTSTRAP_ROOT_DIR) \
+               GOROOT_BOOTSTRAP="$(BOOTSTRAP_ROOT_DIR)" \
                $(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \
                $(HOST_GO_VARS) \
        )
@@ -228,16 +228,16 @@ define Host/Install
 
        $(call GoCompiler/Host/Install/BinLinks,)
 
-       rm -rf $(HOST_GO_ROOT)/pkg/$(GO_HOST_OS_ARCH)$(if $(HOST_GO_INSTALL_SUFFIX),_$(HOST_GO_INSTALL_SUFFIX))
+       rm -rf "$(HOST_GO_ROOT)/pkg/$(GO_HOST_OS_ARCH)$(if $(HOST_GO_INSTALL_SUFFIX),_$(HOST_GO_INSTALL_SUFFIX))"
 
-       $(INSTALL_DIR) $(HOST_GO_ROOT)/openwrt
-       $(INSTALL_BIN) ./files/go-gcc-helper $(HOST_GO_ROOT)/openwrt/
-       $(LN) go-gcc-helper $(HOST_GO_ROOT)/openwrt/gcc
-       $(LN) go-gcc-helper $(HOST_GO_ROOT)/openwrt/g++
+       $(INSTALL_DIR) "$(HOST_GO_ROOT)/openwrt"
+       $(INSTALL_BIN) ./files/go-gcc-helper "$(HOST_GO_ROOT)/openwrt/"
+       $(LN) go-gcc-helper "$(HOST_GO_ROOT)/openwrt/gcc"
+       $(LN) go-gcc-helper "$(HOST_GO_ROOT)/openwrt/g++"
 endef
 
 define Host/Uninstall
-       rm -rf $(HOST_GO_ROOT)/openwrt
+       rm -rf "$(HOST_GO_ROOT)/openwrt"
 
        $(call GoCompiler/Host/Uninstall/BinLinks,)
 
@@ -261,13 +261,13 @@ PKG_GO_ZBOOTSTRAP_MODS:= \
        s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `power8`/;
 
 PKG_GO_VARS= \
-       GOCACHE=$(GO_BUILD_CACHE_DIR) \
+       GOCACHE="$(GO_BUILD_CACHE_DIR)" \
        GOENV=off \
-       GO_GCC_HELPER_PATH=$$$$PATH \
+       GO_GCC_HELPER_PATH="$$$$PATH" \
        CC=gcc \
        CXX=g++ \
        PKG_CONFIG=pkg-config \
-       PATH=$(HOST_GO_ROOT)/openwrt:$$$$PATH
+       PATH="$(HOST_GO_ROOT)/openwrt:$$$$PATH"
 
 PKG_GO_LDFLAGS= \
        -buildid '$(SOURCE_DATE_EPOCH)' \
@@ -283,34 +283,34 @@ PKG_GO_INSTALL_ARGS= \
        $(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie)
 
 define Build/Compile
-       mkdir -p $(GO_BUILD_CACHE_DIR)
+       mkdir -p "$(GO_BUILD_CACHE_DIR)"
 
        @echo "Building target Go first stage"
 
        $(call GoCompiler/Package/Make, \
-               GOROOT_BOOTSTRAP=$(HOST_GO_ROOT) \
+               GOROOT_BOOTSTRAP="$(HOST_GO_ROOT)" \
                GO_GCC_HELPER_CC="$(HOSTCC)" \
                GO_GCC_HELPER_CXX="$(HOSTCXX)" \
                $(PKG_GO_VARS) \
        )
 
        $(SED) '$(PKG_GO_ZBOOTSTRAP_MODS)' \
-               $(PKG_BUILD_DIR)/src/cmd/internal/objabi/zbootstrap.go
+               "$(PKG_BUILD_DIR)/src/cmd/internal/objabi/zbootstrap.go"
 
        @echo "Building target Go second stage"
 
        ( \
-               cd $(PKG_BUILD_DIR)/bin ; \
+               cd "$(PKG_BUILD_DIR)/bin" ; \
                export $(GO_PKG_TARGET_VARS) ; \
                $(CP) go go-host ; \
-               GOROOT_FINAL=$(PKG_GO_ROOT) \
+               GOROOT_FINAL="$(PKG_GO_ROOT)" \
                GO_GCC_HELPER_CC="$(TARGET_CC)" \
                GO_GCC_HELPER_CXX="$(TARGET_CXX)" \
                $(PKG_GO_VARS) \
                ./go-host install -a $(PKG_GO_INSTALL_ARGS) std cmd ; \
-               retval=$$$$? ; \
+               retval="$$$$?" ; \
                rm -f go-host ; \
-               exit $$$$retval ; \
+               exit "$$$$retval" ; \
        )
 endef