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

[QUESTION] Inheritance of file descriptors in <( ... ) construct



Hello,

I'm wondering about the following behaviour:

  % ( fd=; exec {fd}>&2; : $( print foo >&$fd ) )
  foo
  % ( fd=; exec {fd}>&2; : =( print foo >&$fd ) )
  foo
  % ( fd=; exec {fd}>&2; : <( print foo >&$fd ) )
  zsh: 12: bad file descriptor

As you can see, $fd (12) was inherited by the $( ... ) and =( ... ) constructs,
but not by the <( ... ) one.

Everything works as expected with FDs < 10, though:

  % ( fd=9; exec 9>&2; : $( print foo >&$fd ) )
  foo
  % ( fd=9; exec 9>&2; : =( print foo >&$fd ) )
  foo
  % ( fd=9; exec 9>&2; : <( print foo >&$fd ) )
  foo

Is this intended and/or desirable? Maybe something to do with the fact that
<( ... ) is itself exposed as a >=10 file descriptor? But it seems smart enough
not to re-use the number that $fd had (it uses 13 in this example), so...?

Cheers

dana



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