1. stdout and stderr
- Posted by rodoval Sep 04, 2008
- 933 views
Hello all!
Apparently stdout and stderr are not correctly managed by Euphoria (3.1.1 from RDS) in my Linux machine:
test.ex file: puts(1, "To stdout\n") puts(2, "To stderr\n") $ exu test.ex 1> /dev/null output: nothing, instead "To stderr" $ exu test.ex 2> /dev/null output: To stdout (this is correct)
Any idea?
Rodolfo.
2. Re: stdout and stderr
- Posted by jimcbrown (admin) Sep 04, 2008
- 932 views
Hello all!
Apparently stdout and stderr are not correctly managed by Euphoria (3.1.1 from RDS) in my Linux machine:
This is due to hysterical rasins.
Basically, stderr is managed strangely because we used to use ncurses for output. So we'd use the same mechanism to output both stderr and stdout. Nowadays, that mechanism has been changed to always output data through stdout. So when stderr is not being explicitly redirected/piped, eu outputs data to its stdout instead. (This check is done on line 760 of be_w.c) This made sense when eu used ncurses.
3. Re: stdout and stderr
- Posted by ghaberek (admin) Sep 04, 2008
- 955 views
- Last edited Sep 05, 2008
This is due to hysterical rasins.
Hysterical raisins, eh? Those must be some funny fruits!
-Greg
4. Re: stdout and stderr
- Posted by rodoval Sep 05, 2008
- 861 views
Thanks for the reply. It is then possible redirect stdout to a file and stderr to the screen?
Rodolfo.
5. Re: stdout and stderr
- Posted by jimcbrown (admin) Sep 05, 2008
- 864 views
Not trivially. Eu calls isatty() so if you somehow redirect stderr to the tty (say 2> /dev/tty or 2> /dev/console or something) eu will see its still a tty and continue doing its dirty hack.
You could however pipe stderr to another app (such as tee or cat) in a clever way to cause the stderr to go into the pipe and then come out in the other app's stderr. This is as ugly as it sounds. Perhaps even uglier.
Thanks for the reply. It is then possible redirect stdout to a file and stderr to the screen?
Rodolfo.
6. Re: stdout and stderr
- Posted by rodoval Sep 06, 2008
- 838 views
Thanks, this do the trick:
$ exu test.ex 2>&1 1>stdout.txt | cat
Other "solution" is to change
puts(2,"To stderr\n")
for
i=system_exec("echo To stderr 1>&2\n", 2)
in the Euphoria code. This is possibly still more ugly, besides platform dependant.