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: Greg Wooledge
Subject: Re: [Help-bash] Adding missing bash features for safely re-usable bash code
Date: Mon, 8 Apr 2013 17:07:25 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Apr 08, 2013 at 08:58:05PM +0000, adrelanos wrote:
> 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?

If you're using stdout to interact with the user, then you cannot use
stdout to "return" stuff to the caller at the same time.  You'll have
to choose a different option:

 * Return values through a variable in the caller's scope.
 * Manipulate file descriptors (open a new FD writing to /dev/tty and use
   that to write messages on the terminal, instead of stdout).
 * Manipulate file descriptors a different way (dup stdout in a new FD,
   redirect stdout to /dev/tty, interact with the user, then put the
   original stdout back so you can echo stuff to the caller).
 * Return values in a file.

I'm still going with "return values through a variable in the caller's
scope" but you can use whatever works best for your programs.



reply via email to

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