How to export environment variable from a bash script
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Functions are executing in current environment so creating and exporting VARIABLE is the same as if you had typed it in the shell directly, or in the script and run it with source or . (dot) built-in. You can make function by writing it in the shell directly or write it in the script and run script with 'source ./script... =)
Not sure what that was a reference to ... I'm referring
to the fact that this thread is from 2005; it died, got
re-animated in August 2009, died, and got dug up again in
August this year.
Cheers,
Tink
I don't understand what the moderators have against people bringing up old threads. If Google returns this forum thread for a query for a common problem, it shouldn't matter how old the last post was, as long as it is still relevant.
On topic: I was having the same problem using source and export in a bash file, and the leading dot makes it so I the environmental variables appear in the command line after the script finishes. I would like to see someone demonstrate the use of functions though, so I have a second way of fixing the problem should it arise again. If anyone is inclined to include such a demo, I (and all the others who come upon this thread after me) would be very grateful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.