My First Shell Script

I am working on the Android source as a part of my course. And each time that I have to work on it, there are few commands (changing into the Working Directory, loading up the environment variables etc) that have to be run. I wanted to automate it with one command. Hence, created a shell script. I haven’t been totally unexposed to shell scripts but I have never made one.

There wasn’t much trouble doing this except for one. So there is a cd command. Apparently, shell scripts are run in a sub shell. And hence, the directory is changed in the sub-shell and not in your current shell. I looked up online, and found a neat way to work around it. So you need to just source the shell script. For eg.

 source <script_name>

Nice bit of learning experience!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s