From: Glenn Jackman on
At 2010-03-02 12:06PM, "Seebs" wrote:
> On 2010-03-02, PGK <graham.keir(a)gmail.com> wrote:
> > function doit {
> > cd $1/src
> > make
> > cd -
> > }
>
> Note that you don't need the "cd -", because each command is run in its own
> environment, so there's no need to move it back to another directory.

Yes, you do. Functions defined inside {braces} execute in the same
environment. If you use (parentheses), then you get a subshell.

test_cd1() { cd /tmp; } # stays in /tmp after execution
test_cd2() ( cd /tmp; ) # returns to previous cwd

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
From: Kaz Kylheku on
On 2010-03-02, PGK <graham.keir(a)gmail.com> wrote:
> Hi everyone,
>
> I'm trying to write a bash script which will cd into each directory in
> the current one;

Did you look among the examples in your /usr/share/doc/bash
or whereever? :)