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: adrelanos
Subject: Re: [Help-bash] Adding missing bash features for safely re-usable bash code
Date: Mon, 08 Apr 2013 17:51:01 +0000

DJ Mills:
> 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)

This only works if the echo is the end of the function. What about
functions which are supposed to return different strings depending on
if/else?




reply via email to

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