ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Doesn't on my system. (???) I, too, would like answer to this.
Also, when i set an environment variable within a bash script, and 'export' the variable, it only exists as long as the script is running. Are these related symptoms?
Also, when i set an environment variable within a bash script, and 'export' the variable, it only exists as long as the script is running. Are these related symptoms?
Thanks for the link, gilead. I will use that as a reference to hopefully get up to speed on scripting. Maybe i'll also find an answer there to the original alias question that mannahazarika posed.
$ bash --version
GNU bash, version 3.00.16(1)-release (i686-pc-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
... and oddly enough, I now have that behavior. Alias doesn't seem to work. I'm not sure why it was working before, or what I did wrong. Oddly enough, adding a line with 'alias' on it in that shell DOES show the alias being set.
... and oddly enough, I now have that behavior. Alias doesn't seem to work. I'm not sure why it was working before, or what I did wrong. Oddly enough, adding a line with 'alias' on it in that shell DOES show the alias being set.
I am sorry but I did not understand exactly what you meant. Could you please explain it?
-----------------
Makarand Hazarika
NIT Durgapur
Last edited by mannahazarika; 02-24-2006 at 02:58 AM.
Well, to make a long story short, the 'expand_aliases' shell option must be turned on for it to evaluate aliases that have been set. I would've thought that using the 'alias' command would enable expand_aliases, but apparently not.
This is also affected by how the script is run. If the shopt option had already been set in the current shell, its value would be accessible if the script containing the alias were run as:
Code:
source scriptname
However the current shell's shopt option is not available (and the shopt statement needs to be in the script as per Matir's example) when the script is run as:
Code:
./scriptname
The reason for this is that using the source command runs the script in the current shell and gives it access to the current execution environment. However, executing the script standalone (./scriptname) creates a subshell which only inherits a subset of the current shell's environment.
The Command Execution Environment section of `man bash` describes what the environment consists of and how much of it is passed to subprocesses.
This doesn't add much to the discussion, but I found it interesting reading
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.