From b7e18338166e99bef38d80c102b99c65d367f369 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 11 Oct 2019 21:31:44 +0100 Subject: [PATCH] test: Fix fd plumbing In a background process, stdin defaults to /dev/null, so we need to do a little dance. <&0 looks like it ought to work according to the bash manual and does indeed work in bash, but not in dash. This construction seems to work in both. Tested with: date | sh -exc 'cat <&0 >t &' SuS says: If job control is disabled (see set, -m), the standard input for an asynchronous list, before any explicit redirections are performed, shall be considered to be assigned to a file that has the same properties as /dev/null. This shall not happen if job control is enabled. In all cases, explicit redirection of standard input shall override this activity. Signed-off-by: Ian Jackson --- test/invoke | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/invoke b/test/invoke index 98a7ea1..fb9ce2c 100755 --- a/test/invoke +++ b/test/invoke @@ -39,7 +39,8 @@ proc mkconf {which} { set fakeuh [open $fakeuf w 0755] puts $fakeuh "#!/bin/sh set -e -cat >$pipefp.r & +exec 3<&0 +cat <&3 3<&- >$pipefp.r & exec 3<>$pipefp.t exec <$pipefp.t exec 3<&- -- 2.30.2