After logging into my account in linux – I am able to use all the alias I have created in my .bash_profile file.
But after I am executing a simple script (setter.sh) with the command:
cleartool setview view_name
All the alias are getting lost – this could be possibly because cleartool spawns a new shell
Query is:
-
How to determine how many shells are spawned currently – can I know at which nesting level am I currently in – if a script works in such a way that is spawns new shell?.
-
How to retain the alias values after launching new shell – Like in the above case?
-
If I try to ensure that .bash_profile get’s re-executed as part of the script by adding source .bash_profile – even then – the alias setting is not taking place?.
You should have googled on
.bash_profileand you would have found that.bash_profileis for login shells,.bashrcis for interactive shells, and that shell scripts don’t use them.Within shell scripts, better use functions (which you’ll have to define) than aliases.
The shell level of subshells is available thru the
SHLVLvariable.Take time to read the Advanced Bash-Scripting Guide.