title: Bash Function is not getting called, unless I echo the return value
body: <p>In my program I am trying to return a value from a function, the return value is string. Everything works fine(atleast some part), if I echo the value once it is returned, but it is not even calling the function, if I dont return.... Consider the code below....</p>
  
  <pre><code>#!/bin/bash
  
  function get_last_name() {
      echo "Get Last Name"
      ipath=$1
  
      IFS='/'
      set $ipath
      for item
              do
                      last=$item
              done
  
      echo $last
  }
  
  main() {
      path='/var/lib/iscsi/ifaces/iface0'
      current=$(get_last_name "$path")
      echo -n "Current="
      echo $current
  }
  
  
  main
  </code></pre>
  
  <p>It gives me an output like this</p>
  
  <pre><code>OUTPUT
       Current=Get Last Name iface0
  </code></pre>
  
  <p>If I comment the echo $current, then the I am not even seeing the "Get Last Name", which makes to come to conclusion, that it is not even calling the function. Please let me know what mistake I am making. But one thing I am sure, bash is the ugliest language I have ever seen.......</p>