[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: shell script.



> How to return a command from child shell to parent?
> suppose  i want to write a shell script for setting a directory
> for example in dos i will write a bat file
> with commands

You can write a shell script to do the same thing. 

cd /usr/local/lib

is fine but the problem is that when you execute this script, a subshell
gets spawned and only it executes the command and when you return to your
parent shell the working directory will not have changed. 
There are 2 ways of getting around this. One is to make a shell
function.
say 
c() { cd /usr/local/lib ; } 
for bash and put this in your .bash_profile.
Then if u type c<enter> the command gets executed in current shell and so
everything's fine.
otherwise, make an alias
alias c="cd /usr/local/lib"
and it will work too. 
I don't think bash supports the curly braces to execute the given command
in the current shell itself. 



------------------------------------------------------------------------
Trifles make perfection, and perfection is no trifle.
		-- Michelangelo