WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Setting environment variables  (Read 778 times)

Offline polikuo

  • Sr. Member
  • ****
  • Posts: 301
Setting environment variables
« on: January 04, 2017, 09:32:52 PM »
What is the best way to set environment variables for an extension ?
Is there an official way ?  ???

I have some ideas:
  1. Modify ~/.ashrc    with "tce.installed/script"
  2. Modify ~/.profile   with "tce.installed/script"
  3. Add a file into directory /etc/profile.d
      (Must be named as "*.sh", see http://forum.tinycorelinux.net/index.php/topic,5086.msg27095.html)

If one choose to modify "~/.ashrc:~/.profile" with "tce.installed/script"
I can come up 2 ways:
  -- echo lines to the files: echo export FOO=\"Hello World\" >> ~/.ashrc
  -- create config files and source it: echo source /path/to/config/files >> ~/.ashrc

Generally speaking, the benefit of modifying "~/.ashrc:~/.profile" is that the user can use it right away.
However, users might have change their setting, it's not easy to avoid messing up these settings.

On the other hand, by adding a file into directory /etc/profile.d,
the modification would be system wide, but requires a user to log out and log back in.

Any ideas ? ???
« Last Edit: January 04, 2017, 09:35:19 PM by polikuo »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9782
Re: Setting environment variables
« Reply #1 on: January 05, 2017, 01:49:41 AM »
An extension shouldn't modify ~/.profile or ~/.ashrc, unless it's a private one and you know it won't mangle anything. /etc/profile.d is the way.
The only barriers that can stop you are the ones you create yourself.