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

Re: Bash: pipe once more



"Stefan Schmidt" <Stefan.Schmidt@gmx.net> writes:

>> >if I pipe the output of a cd command the working directory doesn't
>> change.
>> 
>> That's because all elements of a pipeline except the last are run in
>> different processes to the main shell that starts the pipeline. As such,
>> the cd command is running in a subshell which exits when cd exits. This
>> has no effect on your main shell, which will keep the original working
>> directory.

>Is there any way to change this behaviour?

Actually, my explanation is wrong. I was confusing it with the behaviour
of zsh.

According to the bash man page:
  Each  command in a pipeline is executed as a separate process (i.e.,
  in a subshell).

This means you cannot run cd in a pipeline. I don't think you can change
this behaviour.


Reply to: