1. stdout and stderr

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.

new topic     » topic index » view message » categorize

2. Re: stdout and stderr

rodoval said...

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: stdout and stderr

jimcbrown said...

This is due to hysterical rasins.

Hysterical raisins, eh? Those must be some funny fruits! smile

-Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: stdout and stderr

Thanks for the reply. It is then possible redirect stdout to a file and stderr to the screen?

Rodolfo.

new topic     » goto parent     » topic index » view message » categorize

5. Re: stdout and stderr

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.

rodoval said...

Thanks for the reply. It is then possible redirect stdout to a file and stderr to the screen?

Rodolfo.

new topic     » goto parent     » topic index » view message » categorize

6. Re: stdout and stderr

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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu