On Mon, 11 Nov 2002, Michael Schwendt wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Mon, 11 Nov 2002 08:55:41 +0100, Ronald Hermans wrote: > > > I wrote a little script to change to an other directory: > > > > #!/bin/bash > > cd /home/ronald/scripts > > clear > > ls -l *.sh > > > > Everything goes allright except the fact that when the script is ended > > I'm still in /home/ronald and not in /home/ronald/scripts > > The scripts folder is in the PATH so I can call the script from any > > place. > > > > What is going wrong? > > Nothing. It is executed in a sub-shell. Instead, you could "source" > your script to execute it for your current shell, e.g. > > $ source test.sh > or: > $ . test.sh
more to the point, it's generally considered bad form to design your scripts so that you *depend* on them to change your environment, such as changing directory, changing environment variables and so on. the exception is, at login time, to source a startup file to perhaps add a number of app-specific environment variables to your current environment. but scripts that incorporate an explicit "cd" that you depend on after the script is over is really unwise. you'd be much better off writing a shell function if that's what you're after. rday -- redhat-list mailing list unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list