Op 12-01-2025 om 21:33 schreef Chet Ramey via austin-group-l at The Open Group:
On 1/10/25 9:00 PM, Lawrence Velázquez via austin-group-l at The Open Group
wrote:
On Fri, Jan 10, 2025, at 7:50 PM, Christoph Anton Mitterer via austin-group-
l at The Open Group wrote:
bash/dash seem to pass on the redirected FDs, but I found at least on
shell wich doesn’t namely, mksh
I assume this is because it wants to mimic ksh93 here.
This behaviour (i.e., 'exec' with only redirections opens file descriptors > 2
close-on-exec) was already in ksh88, and pdksh copied it from there, and mksh
inherited that.
Neither do ksh93u+ 2012-08-01, ksh93u+m/1.0.10 2024-08-01 (except
in posix mode), and OpenBSD 7.6 pdksh.
However, Martijn indicated he's already changed this behavior in
ksh93u+m:
https://austingroupbugs.net/view.php?id=1896#c7025
Yes, though I should point out that the change is subject to the posix shell
option being on.
and would like POSIX to specify that the file descriptors remain open.
I don't know whether Thorsten will follow ksh93 here.
He changed this in mksh well before I did in ksh 93u+m, also for its posix
mode (and its sh mode which is slightly different):
$ mksh -c 'echo $KSH_VERSION'
@(#)MIRBSD KSH R59 2020/10/31
$ mksh -c 'exec 3>&1; sh -c "echo ok >&3"'
sh: 3: Bad file descriptor
$ mksh -o posix -c 'exec 3>&1; sh -c "echo ok >&3"'
ok
$ mksh -o sh -c 'exec 3>&1; sh -c "echo ok >&3"'
ok
Looks like this was done as far back as 2010:
https://github.com/mirbsd/mksh/commit/0c94277c
--
|| modernish -- harness the shell
|| https://github.com/modernish/modernish
||
|| KornShell lives!
|| https://github.com/ksh93/ksh