Re: Preserving standard input for background commands in scripts

2017-10-31 Thread Joerg Schilling
Stephane CHAZELAS wrote: > 2017-10-31 11:38:37 +0100, Joerg Schilling: > [...] > > OK, the Bourne Shell can IO redirection only with a fork. > [...] > > Except for builtins and functions (at least with some versions > like Solaris 10's /bin/sh). > > That seems to

Re: Preserving standard input for background commands in scripts

2017-10-31 Thread Stephane CHAZELAS
2017-10-31 11:38:37 +0100, Joerg Schilling: [...] > OK, the Bourne Shell can IO redirection only with a fork. [...] Except for builtins and functions (at least with some versions like Solaris 10's /bin/sh). That seems to also work for "eval", so one could also do: eval 'cmd <&3 3<&- &' 3<&0;

Re: Preserving standard input for background commands in scripts

2017-10-31 Thread Joerg Schilling
Stephane CHAZELAS wrote: > There's no pipe in: > > { cmd <&3 3<&- & } 3<&0 > pid=$! > > and POSIX does require $! to contain the pid of the process that > executed cmd there. > > As already discussed, the fact that redirected compound commands > were run in a

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Joerg Schilling
Stephane Chazelas wrote: > So an application has to do: > > cmd < /dev/null & > > if it wants to make sure cmd is redirected from /dev/null. > > and: > > { cmd <&3 3<&- & } 3<&0 > > if it wants to work around that (inconsistent) (mis-)feature of > some shells. > >

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Joerg Schilling
Stephane Chazelas wrote: > 2017-10-30 09:24:21 -0400, Chet Ramey: > [...] > > As it reads right now, a reasonable person could infer that `this activity' > > means the behavior described by the rest of the paragraph (`shall be > > considered...'), and that the

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Joerg Schilling
Robert Elz wrote: > Date:Mon, 30 Oct 2017 11:10:59 +0100 > From:Joerg Schilling > Message-ID: > <59f6fab3.e5lk2pfuroy2omt4%joerg.schill...@fokus.fraunhofer.de> > > | Just as a hint: the implicit redirection

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Stephane Chazelas
2017-10-30 09:24:21 -0400, Chet Ramey: [...] > As it reads right now, a reasonable person could infer that `this activity' > means the behavior described by the rest of the paragraph (`shall be > considered...'), and that the /dev/null redirection doesn't happen if > stdin is explicitly redirected

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Chet Ramey
On 10/29/17 7:56 PM, Robert Elz wrote: > | | In all cases, explicit redirection of standard input shall > | | override this activity. > > That last sentence just shouldn't be there - it already says that > the implicit redirect to /dev/null happens before explicit redirects, > which is all

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Robert Elz
Date:Mon, 30 Oct 2017 11:10:59 +0100 From:Joerg Schilling Message-ID: <59f6fab3.e5lk2pfuroy2omt4%joerg.schill...@fokus.fraunhofer.de> | Just as a hint: the implicit redirection to /dev/null happens at the moment | when a

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Joerg Schilling
Robert Elz wrote: > Date:Sun, 29 Oct 2017 21:47:43 + > From:Martijn Dekker > Message-ID: <6432d459-75de-0afe-6716-7960e7a0a...@inlv.org> > > | | In all cases, explicit redirection of standard input shall > | | override

Re: Preserving standard input for background commands in scripts

2017-10-30 Thread Joerg Schilling
Martijn Dekker wrote: > Question: should the last sentence quoted above also apply if standard > input is explicitly redirected to itself? E.g., when running the > following with job control disabled (e.g. as a script) and standard > input on a terminal: > > if [ -t 0 ];

Re: Preserving standard input for background commands in scripts

2017-10-29 Thread Robert Elz
Date:Sun, 29 Oct 2017 21:47:43 + From:Martijn Dekker Message-ID: <6432d459-75de-0afe-6716-7960e7a0a...@inlv.org> | | In all cases, explicit redirection of standard input shall | | override this activity. That last sentence just shouldn't be