Hi List!

I have a question about piping in fish.  In the documentation I read
under “Piping“:

   Pipes usually connect file descriptor 1 (standard output) of the
   first process to file descriptor 0 (standard input) of the second
   process. It is possible use a different output file descriptor by
   prepending the desired FD number and then output redirect symbol to
   the pipe.

I made a little script to test this:
   ea@heldphd6 ~> cat ./oe
   #!/usr/bin/perl -l

   print STDOUT out;
   print STDERR err;


Then, as I would expect:
   ea@heldphd6 ~> ./oe | cat -n
   err
        1       out
   ea@heldphd6 ~> ./oe ^| cat -n
   out
        1       err

The problem I was trying to solve is:  How do I pipe both STDERR and
STDOUT?

These do not work:
   ea@heldphd6 ~> ./oe ^&1 | cat -n
   err
        1       out
   ea@heldphd6 ~> ./oe 2>/dev/stdout | cat -n
   err
        1       out

Of course a named pipe works
   ea@heldphd6 ~> mkfifo p
   ea@heldphd6 ~> ./oe ^p >p & cat -n p
        1       err
        2       out
but this seems needlessly complicated.


While I was trying to figure this out, I noticed some strange
behavior:

   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   err
   ea@heldphd6 ~> ./oe | true
   err
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   err
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   err
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   ea@heldphd6 ~> ./oe | true
   err⏎

Note how ‘err’ is printed only sometimes, and the “carriage return”
sign was printed only once.  The same thing happened with /bin/echo.
If I continue doing this for a while, fish crashes.  (Specifically, it
crashes when I press the ‘up’ key.  There were no crashes using
‘cat’.)

Using the builtin ‘echo’, ‘err’ is always printed, but the crashes
happen much more quickly.

Note: I am using fish 2.0.0.


        Elias

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to