Geoff Clare via austin-group-l at The Open Group wrote in <Z9Aqr5nseOcPND3d@localhost>: |Christoph Anton Mitterer wrote, on 11 Mar 2025: ... |> The remaining problem was that exec doesn't necessarily pass on |> FDs > 2. ... |> [.] and as shells *can* choose not to pass |> on FDs > 2 [.] | |I think previous discussion identified ksh as the only shell which |closes fds > 2; I would expect that in all other shells (or, at least, |all the shells whose behaviour we usually pay attention to) n<&n is a |no-op as long as fd n is already open. From my testing it looks like |it is a no-op in bash, dash, mksh and zsh.
I *think* kre@ has done this not too long ago for the NetBSD (a)sh. (In fact i *think* just ~"last week" a NetBSD old hander came over with problems because the newest NetBSD ships with this updated shell, but it was their usual long thread and i only shortly had a look.) |So I would support updating the standard to require that n<&n and |n>&n are always a no-op if fd n is open, except that if the shell |normally closes fds > 2, that were opened with exec, when it executes |a non-built-in utility, then applying n<&n or n>&n to such commands |causes fd n to remain open. ... --End of <Z9Aqr5nseOcPND3d@localhost> --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
