help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Adding missing bash features for safely re-usable bash c


From: DJ Mills
Subject: Re: [Help-bash] Adding missing bash features for safely re-usable bash code
Date: Mon, 8 Apr 2013 13:15:15 -0400


On Mon, Apr 8, 2013 at 11:52 AM, adrelanos <address@hidden> wrote:
I miss a feature to return non-integers from bash functions, i.e. to
return strings from bash functions.

my_bash_function() {
   return "some_string"
}

string="`my_bash_function`"

There are workarounds, yes, but nothing as simple as the one liner.


''return'' is like ''exit'' for functions, think of it as exit status. What you gave doesn't capture that...
func() {
  echo "some_string"
}

string=$(func)

As an aside, don't use back ticks

reply via email to

[Prev in Thread] Current Thread [Next in Thread]