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