Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #7837

Re: how to I echo debugging remarks inside a function?

From Todd <Todd@invalid.invalid>
Newsgroups comp.os.linux.misc
Subject Re: how to I echo debugging remarks inside a function?
Date 2013-04-10 11:28 -0700
Organization A noiseless patient Spider
Message-ID <kk4arg$20c$1@dont-email.me> (permalink)
References <kk2isa$t64$1@dont-email.me> <lo49t.185675$m21.95467@newsfe02.iad> <87fvyypzwr.fsf@araminta.anjou.terraraq.org.uk>

Show all headers | View raw


On 04/10/2013 01:12 AM, Richard Kettlewell wrote:
> Lew Pitcher <lpitcher@teksavvy.com> writes:
>> Todd@invalid.invalid wrote:
>
>>> I want to echo debugging statements inside a function
>>> the returns its value as an echo.  But I do not want
>>> the debugging echo to be part of the return echo.  I want
>>> the debugging echo to go to the screen instead.
>>>
>>> #!/bin/bash
>>> abc () {
>>>      echo "I want this to go to the screen"
>>>      echo "This goes to the return string"
>>> }
>>> echo "-->$(abc)<--"
>>
>> To get text to appear on your terminal, no matter where stdout & stderr are
>> redirected to, redirect the required output to /dev/tty
>
> That’s a terrible idea, the process may not have a controlling terminal.
> The best places to send debug output are stderr or a logfile.  (See ‘set
> -x’ if you want precedent for using stderr.)
>

Thank you!

#!/bin/bash
abc () {
    echo "I want this to go to the screen" > "/dev/tty"
    echo "I want this to go to the screen too" > "/dev/stderr"
    echo "This goes to the return string"
}
echo "-->$(abc)<--"


$ ./EchoTest
I want this to go to the screen
I want this to go to the screen too
-->This goes to the return string<--

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:33 -0700
  Re: how to I echo debugging remarks inside a function? Lew Pitcher <lpitcher@teksavvy.com> - 2013-04-09 22:46 -0400
    Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:55 -0700
    Re: how to I echo debugging remarks inside a function? Richard Kettlewell <rjk@greenend.org.uk> - 2013-04-10 09:12 +0100
      Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-10 11:28 -0700
        Re: how to I echo debugging remarks inside a function? Lew Pitcher <lpitcher@teksavvy.com> - 2013-04-10 16:20 -0400
          Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-12 11:47 -0700
  Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:49 -0700

csiph-web