Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Workaround: Exporting variables to a parent bash process?

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
2 posts • Page 1 of 1
Author
Message
NeoCORE
Tux's lil' helper
Tux's lil' helper
Posts: 100
Joined: Sat Mar 15, 2003 1:27 pm
Location: Ireland
Contact:
Contact NeoCORE
Website

Workaround: Exporting variables to a parent bash process?

  • Quote

Post by NeoCORE » Fri Jan 12, 2007 11:57 am

Hey guys,

currently writing a script that sets up an environment to do some work with several programs. It asks the user questions and based on that creates a set of variables that suits.

I want those variables to be available in the bash process that the user executed the script in... the only way I have found to do this so far, would be to export all the variables to "~/profile" and then ask the user to perform ". ~/profile" when the execution is completed.

I was hoping there was an easier way to do this, but I cannot find anything on the web that allows this?

Any help would be great :D

Cheers!
To err is human, but to really foul things up, you need a computer :D
NeoCORE Network:)
Adopt a post today! 8)
Top
troymc
Guru
Guru
Posts: 553
Joined: Wed Mar 22, 2006 8:48 am

  • Quote

Post by troymc » Fri Jan 12, 2007 5:17 pm

2 possibilities:

First, if you absolutely need the variables in the *parent* shell, you could have the user source your environment setting script. That way the script will run in the current shell & set the environment variables there.

Code: Select all

 parent sh ---> . ./env.sh ---> parent sh (with env)
Second, if you just need to setup a shell with that environment, have the script exec its own shell (ie. the last line in the script would be "exec /bin/bash"):

Code: Select all

 parent sh |
           |- child sh & ./env.sh ---> child sh (with env)
I hope that makes sense.


troymc
Top
Post Reply

2 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic