title: Pass for loop variable to shell function in makefile
body: <p>How can I pass the value of variable <code>i</code> below to the <code>echo.sh</code> script inside the shell section?</p>
  
  <pre><code>loop:
      for i in 3 2 1; do \
          echo "var i = $$i"; \
          echo $(shell echo.sh $$i); \
      done
  </code></pre>
  
  <p><code>echo.sh</code> could simply be:</p>
  
  <pre><code>#!/bin/bash
  echo $1
  </code></pre>
  
  <p>The output shows </p>
  
  <pre><code>for i in 3 2 1; do \
          echo "var i = $i"; \
          echo ; \
      done
  var i = 3
  
  var i = 2
  
  var i = 1
  </code></pre>
  
  <p>The tricky part is to be able to pass $i to the $(shell ...) makefile function. I haven't been able to figure it out so far.</p>
  
  <p>Thanks</p>
  
  <p>EDIT: Added <code>echo</code> to the <code>$(shell ...</code> line and updated the output. It's trying to run a command. Original question still stands.</p>