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

Re: Bash: pipe once more

On Mon, Jul 14, 2008 at 12:34:08AM -0000, Cameron Hutchison wrote:
> "Stefan Schmidt" <Stefan.Schmidt@gmx.net> writes:
> >> >if I pipe the output of a cd command the working directory doesn't
> >> change.

What are you trying to do ?

maybe something like 

( cd <somwhere>; do something else ) | <and another thing here>

there is also pushd and popd or pwd !

> >> 
> >> 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.
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

"For diplomacy to be effective, words must be credible, and no one can now doubt the word of America."

	- George W. Bush
State of the Union Address

Attachment: signature.asc
Description: Digital signature

Reply to: