Re: I cannot use the 'cd' command in a script

[ Thread Index | Date Index | More lists.tuxfamily.org/slitaz Archives ]


Am 15.04.2011 18:19, schrieb seb:
Hey!
When using the 'cd' command in a script it has no impact on the current
shell :
That's by design.

If you execute a script, then this usually happens in it's own sub-shell which has it's own environment.
Any modification done to the environment therefore applies only to environment of the sub-shell and not the one you started the script in.

If you want the script executed in the current shell you need to call the script with a '.' in front.

E.g. ':~# . /etc/script.sh' instead of ':~# /etc/script.sh'

Thereafter you should be in the directory you cd'd into.

Rgds.,
Klaus

---
SliTaz GNU/Linux Mailing list - http://www.slitaz.org/


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/