How can I terminate Makefile with an error if shell command output an $$? -ne 0 ?
HELPER := $(shell dirname $(abspath $(lastword
VERSION ?= $(shell . $(HELPER); getVersion) || (echo "getVersion failed '$$?' status"; exit 1)
test:
@echo "What is going on?$(VERSION) ?"
helper.sh:
#!/bin/bash
printError() {
echo "[MAKE] $1" 2>/dev/stderr
}
getVersion() {
version=$(git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null)
if [ $? -ne 0 ]; then
printError "Getting git tag for version failed. Checkout existing tag or"
printError "provide your own version 'make <action> VERSION=<your-version>'"
exit 1
fi
echo "${version}"
exit 0
}
output:
$ make test
What is going on?[MAKE] Getting git tag for version failed. Checkout existing tag or [MAKE] provide your own version 'make <action> VERSION=<your-version>' || (echo getVersion failed $? status; exit 1) ?
I cannot terminate it on error ( getVersion returns 1 ) but also error messages that are piped to /dev/stderr
are getting to VERSION
variable