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.
Experiment shows no can do; if you assign a value to a variable that is an environment variable then the environment variable is changed. Maybe you are asking us to fix a sub-optimal solution; what do you want to achieve?
You can use () so the shell will do a fork. But the variable changing can't be on the same line because the shell will resolve variables before they are changed.
When you told the shell to run a program with a specific environment variable set to whatever, it did exactly that for the new process created. It did not change the environment variable in the current environment.
This is so something like this will work and not screw things up:
When you told the shell to run a program with a specific environment variable set to whatever, it did exactly that for the new process created. It did not change the environment variable in the current environment.
Right, it seemed to me that the OP was in fact asking to not change the environment variable in the current environment even though this is the default behaviour. Possibly I've totally misunderstood what everyone has been saying, if so just ignore me.
Last edited by ntubski; 12-02-2010 at 11:55 AM.
Reason: grammar
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.