title: How to get a variable to have the current dir path?
body: <p>I have a really simple function in bash script that tells me the current directory. However it gives the error <code>bash: =/home/users/abc: No such file or directory</code> $currentdir is empty.</p>
  
  <p>Why is this happening? I also tried </p>
  
  <pre><code>$currentdir=`pwd` 
  </code></pre>
  
  <p>and that didn't work too.</p>
  
  <p>This is a similar question <a href="https://stackoverflow.com/questions/13275013/bash-current-directory-variable">Bash: current directory variable</a> and I tried this but it didn't solve my problem.</p>
  
  <pre><code>xpwd() {
      $currentdir=$(pwd)
      echo "current dir is $currentdir"
  }
  </code></pre>