[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash: pipe once more



Title: Re: Bash: pipe once more

Allan Wind wrote:

> cd does not seem to do its thing when stdout is redirected to a pipe,
> however it does work with a (temporary) file:

Actually, cd does do its thing--it's just that its thing applies to the subprocess
shell in the pipe instead of the shell it would normally apply to (when not
run in a pipe subshell), so you don't see it.

To see that, run the sequence:

   pwd
   ( cd some-subdirectory ; pwd ) | cat
   pwd

The second pwd's output will show that cd did its thing.  (And, of course,
the third will show what it doesn't do (that its effect is limited to the
pipe/subshells).)


Daniel
--
(Plain text sometimes corrupted to HTML "courtesy" of Microsoft Exchange.)



Reply to: