Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Redirect a specific file descriptor to a pipe?



On Sat, Mar 11, 2017 at 12:32 AM, Nathan Dorfman <ndorfman@xxxxxxxxx> wrote:
> On Fri, Mar 10, 2017 at 11:51 AM, Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
>> } In zsh, to avoid the multios effect, you can do:
>> }
>> } {strace -o /dev/fd/3 ./a.out 3>&1 > out.log 2> err.log} | less
>> }
>> } or disable multios (set +o multios).
>>
>> With multios and without the braces, out.log gets the a.out output
>> and less gets both the strace output and the a.out output, which is
>> actually what I meant to do (but might not be exactly what Nathan
>> wanted, in retrospect).  Thanks for the correction.
>
> Thanks guys, this does actually answer my question, and makes sense
> now that I think about.
>
> I still think it might be useful to be able to pipe any fd, not just
> stdout, but I don't know if I can contrive a great example. Perhaps we
> can't redirect stdout because it's a curses program that needs direct
> terminal access, but we want to do something like this:
>
> strace -o /dev/fd/3 mutt 3>XXX
>
> Where instead of XXX, we want to send fd 3 to |xz or |ssh?
>
> Feel free to ignore me if you think I'm going off the deep end :)

you can in theory do this

whatever_command 5> >(pipe command here) 7> >(some other pipe here)

but now that i'm testing it, it seems to not complete when it should, eg
strace -o /dev/fd/7 =true 7>&1 | cat
immediately returns but
strace -o /dev/fd/7 =true 7> >(cat)
just hangs after printing the output

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author