title: local:not in a function for variable
body: <p>I keep getting "12: local: not in a function" for the code below, which is the first line where "local log" appears. The local variables appear to be set properly in the function. Could someone please point me in the right direction?</p>
  
  <pre><code>#!/bin/bash
  
  HOST="0.0.0.0"
  USER="root"
  PASS="123"
  
  function login{
   if [ -z "$USER" ]
   then
     echo "pass not set"
   else 
     local log="-u $USER"
     local log+="-p$PASS"
     echo $log
  fi 
  }
  
  mysql (login) -h $HOST
  </code></pre>
  
  <p>This is on the Ubuntu subsystem on Win 10 in case that matters.</p>