[prog] Returning a string from a function, in bash
Dominik Schramm
dominik.schramm at gmxpro.net
Fri Apr 16 00:17:57 EST 2004
Hi,
"Riccarda Cassini" <riccarda.cassini at gmx.de> writes:
> myfunc ()
> {
> local arg=$1
> echo "arg was: $arg"
> }
>
> par=test
> var=`myfunc $par`
>
> This seems to work, so I basically could be happy with it. However, I'm
> a little unsure as to whether this is the way one's supposed to do it.
That's the only possibility that I can think of.
There is a "return" builtin in bash, but it cannot have an argument:
it just exits the function.
Do you know the Advanced Bash Scripting Guide?
http://www.tldp.org/LDP/abs/html/index.html
Lots of -- the title is not unclear about it -- advanced scripting tips
and tricks. You may really certainly like it.
regards,
dominik
ps: don't know if you already got personal responses, but on techtalk
(which among other things discusses "everything shells") you may have
better chances to get an answer.
More information about the Programming
mailing list