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: John Kearney
Subject: Re: [Help-bash] Adding missing bash features for safely re-usable bash code
Date: Mon, 08 Apr 2013 23:08:45 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

Am 08.04.2013 22:58, schrieb adrelanos:
> Greg Wooledge:
>> On Mon, Apr 08, 2013 at 05:51:01PM +0000, adrelanos wrote:
>>> What about
>>> functions which are supposed to return different strings depending on
>>> if/else?
>> If you are using the stdout capturing paradigm, nothing prevents you
>> from doing so inside an if statement:
> What if I am using echo for communicating with the user (output) and
> don't want the echo each internal return value to the user?
>
What I generally do is

exec 0>3
exec 1>4
exec 2>5

ks_con_Out() {
    echo "address@hidden" >&4   
}

that way stdout is only for return values.

if all you want o do is return value in bash then its better to use the
folloing approach

# Arg 1 value to set with return value
func_sample() {
   printf -v "${1}" "%s" "Return Value"
}








reply via email to

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