Re: Shell Command Substitution and fork()

2016-06-21 Thread Robert Elz
I should add a caution - don't just blindly use those code fragments, they all (or at least most) have bugs - most easy to fix, but I was just being quick & dirty with them as examples... kre

Re: Shell Command Substitution and fork()

2016-06-21 Thread Robert Elz
Date:Tue, 21 Jun 2016 23:27:41 +0200 From:Edgar =?iso-8859-1?B?RnXf?= Message-ID: <20160621212740.gl12...@trav.math.uni-bonn.de> | So it's probably hard to get right. Non trivial yes, some of the things that can be done which have to be undone are var assignments,

Re: Shell Command Substitution and fork()

2016-06-21 Thread Edgar Fuß
EF> Unsurprisingly, [ast-ksh] doesn't fork. EF> Does anyone know how those ksh's achieve that? kre> I haven't look at their sources, but I would assume they don't fork. I concur. The most probable way to achieve non-forking is not to fork. EF> Are there any drawbacks? kre> [ash] already has co

Re: Shell Command Substitution and fork()

2016-06-21 Thread Edgar Fuß
> so why don't you use PDKSH (/bin/ksh) or pkgsrc's ast-ksh instead of ash > (/bin/sh) ? Even pkgsrc's GNU Bash would do. Err, what? pdksh performs worse that ash. bash surely performs worse. Both fork. Overall, I don't write for a specific shell, I write for POSIX shells. While that particular s

Re: Shell Command Substitution and fork()

2016-06-21 Thread Pierre-Philipp Braun
Hello Edgar, so why don't you use PDKSH (/bin/ksh) or pkgsrc's ast-ksh instead of ash (/bin/sh) ? Even pkgsrc's GNU Bash would do. I do x=`command` which is almost the same as $(command), using any KSH or BASH as interpreter. I don't really care about POSIX here as KSH and BASH syntax is m

Re: Shell Command Substitution and fork()

2016-06-21 Thread Robert Elz
Date:Tue, 21 Jun 2016 20:46:11 +0200 From:Edgar =?iso-8859-1?B?RnXf?= Message-ID: <20160621184611.gi12...@trav.math.uni-bonn.de> | Does anyone know how those ksh's achieve that? Are there any drawbacks? I haven't look at their sources, but I would assume they don't

Shell Command Substitution and fork()

2016-06-21 Thread Edgar Fuß
I have a shell script that makes heavy use of Command Substitution, i.e. x="$(some-command)" The script takes several seconds to execute, mainly because Command Substitution takes place in a Subshell Environment and that usually means a fork(). However, the OS X^W^WmacOS ksh only takes te