Bash Function is not getting called, unless I echo the return value
===

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....


    #!/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

It gives me an output like this

    OUTPUT
         Current=Get Last Name iface0

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.......
