title: Using a variable in brace expansion range fed to a for loop
body: <p>Here is myscript.sh</p>
  
  <pre><code>#!/bin/bash
  for i in {1..$1};
  do
      echo $1 $i;
  done
  </code></pre>
  
  <p>If I run <code>myscript.sh 3</code> the output is</p>
  
  <pre><code>3 {1..3}
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>3 1
  3 2
  3 3
  </code></pre>
  
  <p>Clearly <code>$3</code> contains the right value, so why doesn't <code>for i in {1..$1}</code> behave the same as if I had written <code>for i in {1..3}</code> directly?</p>