Message-ID: <3251C377.3134@cs.com> Date: Tue, 01 Oct 1996 18:20:55 -0700 From: "John M. Aldrich" Reply-To: fighteer AT cs DOT com Organization: Three pounds of chaos and a pinch of salt MIME-Version: 1.0 To: Eli Zaretskii CC: Daisuke Aoyama , djgpp-workers AT delorie DOT com Subject: Re: bash 1.14.7 is available References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > > I found something strange about the `(commands)' construct. Try this: > > bash -c '(cd .. | ls)' > > You will see the listing of the *current* directory, not of its parent, > from `ls'. I've tried this with a Unix `sh', and it works the same, but > `ms_sh' does produce the listing of the parent (and I do find this latter > behavior more intuitive). What am I missing here? Forgive me for intruding here, but I think I can take a guess. Under MS-DOS, asynchronous pipes are not possible. When you open a pipe for reading, the program is executed in its entirety and its output is redirected to the file pointer. When you open it for writing, the program is not executed until the pipe is closed. However, in the latter case I believe that the command is actually evaluated by the shell at the time of the pipe's opening. (Please correct me if I'm wrong here.) Thus, the pipe to 'ls' would be opened before 'cd' had actually changed the directory, causing its environment to specify the current directory instead of the parent. If this is indeed the case then you couldn't just use an ordinary 'pipe()' call in the shell; a workaround would have to be found. Perhaps 'ms_sh' addresses this problem while the others do not? > Btw, if you replace `|' with a `;', it lists the parent directory. For obvious reasons. (The processes are executed sequentially, not (a)synchronously.) :) -- John M. Aldrich * Anything that happens, happens. * Anything that, in happening, causes something else to happen, causes something else to happen. * Anything that, in happening, causes itself to happen again, happens again. * It doesn't necessarily do it in chronological order, though. --- Douglas Adams