CodeLibary.com - code examples
  Home  Submit  Free Hosting  Link To Us  Contacts

Bash Passing an indirect reference to a function

Bash Passing an indirect reference to a function Bash Bash Passing an indirect reference to a function Download (.zip)

#!/bin/bash
# ind-func.sh: Passing an indirect reference to a function.

echo_var ()
{
echo "$1"
}

message=Hello
Hello=Goodbye

echo_var "$message"        # Hello
# Now, let's pass an indirect reference to the function.
echo_var "${!message}"     # Goodbye

echo "-------------"

# What happens if we change the contents of "hello" variable?
Hello="Hello, again!"
echo_var "$message"        # Hello
echo_var "${!message}"     # Hello, again!

exit 0


  Sponsored Links

  Partners
My Linux Space




Home | Bookmark Us | Terms of Use | Link to us | Contact Us

Programming sites at Top100.ws Tatet 

Copyright 2007 © CodeLibary.com, All rights reserved.

Bash Passing an indirect reference to a function