Hi Chet, On Mon, Dec 30, 2013 at 11:33:43AM -0500, Chet Ramey wrote: > On 12/30/13 11:22 AM, Suvayu Ali wrote: > > Hi, > > > > On Thu, Dec 26, 2013 at 06:22:19PM -0500, Chet Ramey wrote: > >> On 12/25/13, 1:33 AM, Pierre Gaston wrote: > >> > >>> If I remember correctly, POSIX allows the lastpipe behaviour. > >> > >> It does, in its usual fashion: "each command of a multi-command pipeline > >> is in a subshell environment; as an extension, however, any or all > >> commands in a pipeline may be executed in the current environment." > > > > Is there any technical reason to choose one over the other? Or is it > > not really a choice, and is determined by other limitations of the > > shell? > > It simply doesn't work at all in a job control environment; to make that > work requires a fork-on-the-fly-at-the-point-of-suspend strategy and a > lot of ex post facto process group twiddling. That's way more trouble > than it's worth. > > In terms of behavioral consistency, it's a lot easier and more consistent > to say that all components of a pipeline are executed in subshell > environments, and that they do not affect their parent's environment. > > There are not that many other technical impediments to running the last > component in the calling shell. The one you have to pay the most attention > to is making sure that all the pipe file descriptors get closed where they > should, and making sure that all of the other commands in the pipeline get > reaped properly.
Thanks a lot, I think I follow the complications involved in executing in the current environment. Cheers, PS: Wish you a happy new year :) -- Suvayu Open source is the future. It sets us free.