From 0947d274f62c30e8a03a4f189bbe8ead3e0475d6 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 20 Mar 2015 23:37:29 +0000 Subject: [PATCH] use a perl test for fd-cloexec to avoid testing the tester with the tester; improve fd-cloexec description --- check.t | 42 +++++++++++++++++++++++++++--------------- lksh.1 | 18 ++++++++++++------ 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/check.t b/check.t index 079fc40..485bc68 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.685 2015/03/14 05:23:12 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.686 2015/03/20 23:37:27 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -9756,25 +9756,33 @@ description: Verify that file descriptors > 2 are private for Korn shells AT&T ksh93 does this still, which means we must keep it as well category: shell:legacy-no -file-setup: file 644 "test.sh" - echo >&3 Fowl stdin: - exec 3>&1 - "$__progname" test.sh + cat >cld <<-EOF + #!$__perlname + open(my \$fh, ">&", 9) or die "E: open \$!"; + syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; + EOF + chmod +x cld + exec 9>&1 + ./cld expected-exit: e != 0 expected-stderr-pattern: - /bad file descriptor/ + /E: open / --- name: fd-cloexec-2 description: Verify that file descriptors > 2 are not private for POSIX shells See Debian Bug #154540, Closes: #499139 -file-setup: file 644 "test.sh" - echo >&3 Fowl stdin: - test -n "$POSH_VERSION" || set -o sh - exec 3>&1 - "$__progname" test.sh + cat >cld <<-EOF + #!$__perlname + open(my \$fh, ">&", 9) or die "E: open \$!"; + syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; + EOF + chmod +x cld + test -n "$POSH_VERSION" || set -o posix + exec 9>&1 + ./cld expected-stdout: Fowl --- @@ -9782,11 +9790,15 @@ name: fd-cloexec-3 description: Verify that file descriptors > 2 are not private for LEGACY KSH category: shell:legacy-yes -file-setup: file 644 "test.sh" - echo >&3 Fowl stdin: - exec 3>&1 - "$__progname" test.sh + cat >cld <<-EOF + #!$__perlname + open(my \$fh, ">&", 9) or die "E: open \$!"; + syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; + EOF + chmod +x cld + exec 9>&1 + ./cld expected-stdout: Fowl --- diff --git a/lksh.1 b/lksh.1 index 31dc6ff..28c6a18 100644 --- a/lksh.1 +++ b/lksh.1 @@ -1,6 +1,6 @@ -.\" $MirOS: src/bin/mksh/lksh.1,v 1.5 2013/05/22 18:18:06 tg Exp $ +.\" $MirOS: src/bin/mksh/lksh.1,v 1.6 2015/03/20 23:37:29 tg Exp $ .\"- -.\" Copyright (c) 2008, 2009, 2010, 2012, 2013 +.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015 .\" Thorsten “mirabilos” Glaser .\" .\" Provided that these terms and disclaimer and all copyright notices @@ -72,7 +72,7 @@ .\" with -mandoc, it might implement .Mx itself, but we want to .\" use our own definition. And .Dd must come *first*, always. .\" -.Dd $Mdocdate: May 22 2013 $ +.Dd $Mdocdate: March 20 2015 $ .\" .\" Check which macro package we use, and do other -mdoc setup. .\" @@ -245,11 +245,17 @@ passes through the errorlevel from the .Xr getopt 1 command. .It -.Nm lksh , -unlike +Unlike .At .Nm ksh , -does not keep file descriptors \*(Gt 2 private. +.Nm mksh +in +.Fl o Ic posix +or +.Fl o Ic sh +mode and +.Nm lksh +do not keep file descriptors \*(Gt 2 private from sub-processes. .El .Sh SEE ALSO .Xr mksh 1