I've found the command intuitive but the documentation confused me a
little bit.

So here's a patch.

 ISTR you actually submitted the same thing a few months ago and I did
not react. Sorry, I should have replied sooner.

 The documentation is correct and I won't apply the patch. But it's
not your fault : you are right that it is a confusing matter.

 The confusion comes from a commonly wrong intuition of what a file
descriptor is. When you "move file descriptors" (typically via dup2(),
which fdmove is implemented over), the move goes in the opposite
direction from what we intuitively think, because we tend to see
the numbers as fixed and the data flows as changing - but the
opposite is happening: the data flow does not change, the numbering

 If you send a mail to "Alice" and it ultimately arrives to "Bob",
then you get the impression that "Alice" and "Bob" are two separate
entities and that your mail went *from Alice to Bob*. But that's
not what's happening with file descriptors. What really happened
is that Bob changed their name *from Bob to Alice*, and when you
send mail to Alice, it reaches the correct recipient that your mind
still identifies as Bob.
 (Please don't deadname file descriptors, or people. It's rude.)

 So when you do "fdmove 2 1", the data you send as what you still
perceive as stderr will now be sent to what you still perceive as
stdout, so you think fdfrom is 2 and fdto is 1. But the reality is
that your perception is wrong - what happened is that stdout just
changed its numbering *from 1 to 2*, so it's now called stderr.

 You now have the responsibility to untangle the confusion among your
friends and co-workers when it arises. :)


Reply via email to