Can I set up my own sub-environment?

Paul Smith paul at mad-scientist.net
Tue Feb 8 14:40:07 UTC 2011


On Tue, 2011-02-08 at 03:02 -0800, Sven-Göran Bergh wrote:
> > >  - pushd & popd,  not in ash
> > 
> > But you can do simple:
> > 
> >     cd  /foo
> >     cd -
> 
> This is not the same as pushd and popd. A workaround with aliases
> may work though:

For shell scripts the simplest solution is often to use a subshell:

        ( cd /foo; : do some stuff; )

when the shell exits you're back where you started (obviously you can't
do everything like this, such as setting variables etc., but it's
perfect for jumping somewhere else and running a command, then coming
back).



More information about the busybox mailing list