Rajeev Jha forced the electrons to say:
> worst part is that cd command has an exit status of 0, would like someone
> to clear this point
Shell scripts are executed by bash in what is known as a subshell. A subshell
is a child of your login shell, and changes you make in a subshell is not
visible in parent shells.
The shell inbuilt variable SHLVL counts the heirarchy level of the current
invocation of bash. So, your login shell has $SHLVL as 1, and in your script
you will find $SHLVL = 2.
In a similar way, any variable you set/export in a subshell is not visible in
the parent shell. So, you cannot set your environment like PATH etc. in a
shell script.
Bash provides a method my which a script can be executed in the current shell
itself. Instead of invoking the script as
sh script.sh
you invoke it as
. script.sh
or, alternatively
source script.sh
and the commands in script.sh are executed in the current shell.
Binand
--
The prompt for all occasions:
export PS1="F:\$(pwd | tr '/[a-z]' '\134\134[A-Z]')> "
--------------- Binand Raj S. ([EMAIL PROTECTED])
-----------------------------------------------------------------------
For more information on the LIH mailing list see:
http://lists.linux-india.org/lists/LIH