title: Difference between ksh and bash script
body: <p>Consider the following script (arithmetic syntax that is used for local_var2 is irrelevant for this case):</p>
  
  <pre><code>#!/bin/ksh
  
  function my_func1
  {
     typeset local_var1=one
     typeset local_var2
     (( local_var2 = 1 ))
     echo my_func1: local_var1 = $local_var1, local_var2 = $local_var2
  }
  
  my_func2()
  {
     typeset local_var1=two
     typeset local_var2
     (( local_var2 = 2 ))
     echo my_func2: local_var1 = $local_var1, local_var2 = $local_var2
  }
  local_var1=0
  local_var2=0
  echo before functions: local_var1 = $local_var1, local_var2 = $local_var2
  
  my_func1
  echo after my_func1: local_var1 = $local_var1, local_var2 = $local_var2
  
  my_func2
  echo after my_func2: local_var1 = $local_var1, local_var2 = $local_var2
  </code></pre>
  
  <p>When run it produces the following output:</p>
  
  <pre><code>before functions: local_var1 = 0, local_var2 = 0
  my_func1: local_var1 = one, local_var2 = 1
  after my_func1: local_var1 = 0, local_var2 = 0
  my_func2: local_var1 = two, local_var2 = 2
  after my_func2: local_var1 = two, local_var2 = 2
  </code></pre>
  
  <p>(which is not what is expected!)</p>
  
  <p>If I run the same script in bash, the output is:</p>
  
  <pre><code>before functions: local_var1 = 0, local_var2 = 0
  my_func1: local_var1 = one, local_var2 = 1
  after my_func1: local_var1 = 0, local_var2 = 0
  my_func2: local_var1 = two, local_var2 = 2
  after my_func2: local_var1 = 0, local_var2 = 0
  </code></pre>
  
  <p>(which is what is expected!)</p>