Makefile: Use a POSIX-compatible test ('==' -> '=')

With dash 0.5.7:

  # make docs
  /bin/sh: 1: test: 1.3.3: unexpected operator
  /bin/sh: 1: test: 1.3.3: unexpected operator
  /bin/sh: 1: test: 1.3.3: unexpected operator
  Makefile:47: *** cannot build output//oci-runtime-spec.pdf without either pandoc or docker.  Stop.
  # command -V test
  test is a shell builtin

POSIX defines '=' for string comparison [1]; the '==' form is a
Bashism.

SHELL was added in f3fdf03 (Makefile: prefer bash, 2016-05-25, #455)
to avoid these "unexpected operator" errors, but there's no reason to
require Bash when we can make the comparison's POSIX compliant.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

Signed-off-by: W. Trevor King <wking@tremily.us>
This commit is contained in:
W. Trevor King 2016-08-26 08:04:20 -07:00
parent 069e8e1c16
commit ad9d643c3d
1 changed files with 1 additions and 2 deletions

View File

@ -2,7 +2,6 @@
EPOCH_TEST_COMMIT := 78e6667ae2d67aad100b28ee9580b41b7a24e667 EPOCH_TEST_COMMIT := 78e6667ae2d67aad100b28ee9580b41b7a24e667
OUTPUT_DIRNAME ?= output/ OUTPUT_DIRNAME ?= output/
DOC_FILENAME ?= oci-runtime-spec DOC_FILENAME ?= oci-runtime-spec
SHELL ?= $(shell command -v bash 2>/dev/null)
DOCKER ?= $(shell command -v docker 2>/dev/null) DOCKER ?= $(shell command -v docker 2>/dev/null)
PANDOC ?= $(shell command -v pandoc 2>/dev/null) PANDOC ?= $(shell command -v pandoc 2>/dev/null)
ifeq "$(strip $(PANDOC))" '' ifeq "$(strip $(PANDOC))" ''
@ -63,7 +62,7 @@ version.md: ./specs-go/version.go
HOST_GOLANG_VERSION = $(shell go version | cut -d ' ' -f3 | cut -c 3-) HOST_GOLANG_VERSION = $(shell go version | cut -d ' ' -f3 | cut -c 3-)
# this variable is used like a function. First arg is the minimum version, Second arg is the version to be checked. # this variable is used like a function. First arg is the minimum version, Second arg is the version to be checked.
ALLOWED_GO_VERSION = $(shell test '$(shell /bin/echo -e "$(1)\n$(2)" | sort -V | head -n1)' == '$(1)' && echo 'true') ALLOWED_GO_VERSION = $(shell test '$(shell /bin/echo -e "$(1)\n$(2)" | sort -V | head -n1)' = '$(1)' && echo 'true')
.PHONY: test .govet .golint .gitvalidation .PHONY: test .govet .golint .gitvalidation