[prog] Returning a string from a function, in bash
Riccarda Cassini
riccarda.cassini at gmx.de
Fri Apr 16 14:51:12 EST 2004
Hi Conor,
> myfunc()
> {
> echo `command and result`
> local result=$?
> if [ $result -eq 0 ]; then # you can also test on $? itself but only
once
> return 0
> fi
> return 1
> }
is there a specific reason for explicitly returning 0 and 1, rather
than just writing "return $?". I would've thought that if you test
for "-ne 0" on the return code afterwards, the net effect would be
the same (at least if there's no other code in between). Is there
some subtle issue with "return $?" - which, as I understand it, would
sort of assign $? to itself? (serious question, not just wanting to
be clever).
Thanks,
Riccarda
--
NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/info
More information about the Programming
mailing list