title: Difference between "${param[0]}" and ${1} in bash
body: <p>I'm looking at some old scripts and I found some parameter assignment that I have not seen before. A while loop reads from a text file and passes the values to a function. The items in the text file look like this:</p>
  <pre><code>user_one:abcdef:secretfolder
  </code></pre>
  <p>the first stage of the function then looks like this:</p>
  <pre><code> IFS=':' read -a param &lt;&lt;&lt; $@
  
   user=&quot;${param[0]}&quot;
   pass=&quot;${param[1]}&quot;
   user_folders=&quot;${param[2]}&quot;
  </code></pre>
  <p>I have not seen this sort of assignment before and was wondering if this is just an alternative way of handling it. Is the above the same as this?</p>
  <pre><code>IFS=':' read -a param &lt;&lt;&lt; $@
  
  user=&quot;${1}&quot;
  pass=&quot;${2}&quot;
  user_folders=&quot;${3}&quot;
  </code></pre>
  <p>(change in values to 1-3 due to <code>${0}</code> being the name of the file itself). This script is 5 years old; This original sort of assignment just seems a longer way to to it, unless I've missed something</p>
  <p>I'm still learning shell scripting but as I understand, setting <code>IFS=':'</code> will split the fields on <code>:</code> rather than whitespace and so in the examples, the value of <code>&quot;${param[0]}&quot;</code> and <code>${1}</code> passed to the function would be <code>user_one</code></p>
  <p>Can someone please explain if there is a reason why <code>&quot;${param[0]}&quot;</code> should be used instead of <code>${1}</code>?</p>