Date: Tue, 21 Jun 2016 20:46:11 +0200 From: Edgar =?iso-8859-1?B?RnXf?= <e...@math.uni-bonn.de> 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 fork. | Could ash be taught the same thing? It already has code to attempt to do that, but it doesn't currently work properly in all cases, so has been disabled (long ago). Of course there is only a big speedup when the command is a shell builtin, but printf qualifies (as does echo of course) for that. But even for other cases, when this eventually gets fixed other (simple) commands would be able to just vfork() - as it is now a full fork() is required. [As I understand it, the issue is with correct cleanup, especially in the case of errors - nothing n the sub-shell environ is allowed to affect the parent shell, so anything in the cmd-sub that changes anything at all has to be undone - fork() makes that simple to get right, exit() cleans up everything...] | Or can someone think of a POSIX-compliant way to put the output of a | command (think printf) into a variable without Command Substitution? In general, no, that's what command substitution is for after all (to get the output of a command into the command line, so it can then be assigned, or whatevr other use you need it for.) But in some cases, depending upon exactly what the printf is doing, there can be other ways. kre