title: Accessing script positional parameters inside a function
body: <p>Test script:</p>
  
  <pre><code>#!/bin/bash
  var=$1
  function test {
  echo "dollar1 $1"
  echo "var $var"
  }
  test
  exit
  </code></pre>
  
  <p>output</p>
  
  <pre><code>./test.sh d
  dollar1
  var d
  </code></pre>
  
  <p>Why isn't <code>$1</code> populated inside the function, and is there a way to pass <code>$1</code>...<code>$n</code> to all functions without having them defined as a variable separately?</p>