Skip to content

Commit

Permalink
fix: use printf rather than echo for escaping in cliv2 Makefile (#4559)
Browse files Browse the repository at this point in the history
`cliv2/Makefile` is using echo in a way that relies on MacOS/zsh specifics,
where `echo` will interpret escape sequences by default.  This not the case
everywhere. Using `echo -e` works on some platforms (zsh and bash) but it's
not part of POSIX, so using `printf` is the most idiomatic way to do it.
  • Loading branch information
jaspervdj-snyk committed Apr 19, 2023
1 parent b51371c commit c074f6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cliv2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ $(CACHE_DIR)/version.mk: $(CACHE_DIR)
ifeq ($(CLI_V1_VERSION_TAG), $(_EMPTY))
$(eval CLI_V1_VERSION_TAG := $(shell curl --fail --progress-bar -L https://static.snyk.io/cli/latest/version))
endif
@echo "CLI_V1_VERSION_TAG=$(CLI_V1_VERSION_TAG)\nCLI_V2_VERSION_TAG=$(CLI_V2_VERSION_TAG)" > $(CACHE_DIR)/version.mk
@printf "CLI_V1_VERSION_TAG=$(CLI_V1_VERSION_TAG)\nCLI_V2_VERSION_TAG=$(CLI_V2_VERSION_TAG)" > $(CACHE_DIR)/version.mk
@echo "$(LOG_PREFIX) Using cliv1 version ( $(CLI_V1_VERSION_TAG) )"
@echo "$(LOG_PREFIX) Building cliv2 version ( $(CLI_V2_VERSION_TAG) )"

Expand All @@ -112,7 +112,7 @@ $(CACHE_DIR):
@mkdir $@

$(CACHE_DIR)/variables.mk: $(CACHE_DIR)
@echo "GOOS=$(GOOS)\nGOARCH=$(GOARCH)\n" > $(CACHE_DIR)/variables.mk
@printf "GOOS=$(GOOS)\nGOARCH=$(GOARCH)\n" > $(CACHE_DIR)/variables.mk

$(V1_DIRECTORY)/$(V1_EMBEDDED_FILE_OUTPUT):
@echo "$(LOG_PREFIX) Generating ( $(V1_DIRECTORY)/$(V1_EMBEDDED_FILE_OUTPUT) )"
Expand Down

0 comments on commit c074f6c

Please sign in to comment.