Re: /etc/profile.d
goswin.brederlow@student.uni-tuebingen.de (Goswin Brederlow) writes:
> The only way to set a enviroment variable would be to add it to
> /etc/enviroment and if thats against policy, who ses LANG in
> /etc/enviroment?
There is a slight problem with the way /etc/environment is currently
handled in Debian, though. The format of /etc/environment is
VARIABLE1=VALUE1
VARIABLE2=VALUE2
...
And this works just fine if you log in via ssh, which reads and
interprets /etc/environment on its own. If you log in on the console
or via telnet, /etc/environment will not automatically be read and you
need to read it from /etc/profile. The way that is done by default in
Debian (please correct me if this is no longer the case) is by this
segment of code:
if [ -f /etc/environment ]; then
. /etc/environment
fi
The problem is that the variables are not exported when
/etc/environment is just sourced! To get around this problem, the
code in /etc/profile to initialize the environment needs to be a bit
more clever. What I currently use is this:
if [ -f /etc/environment ]; then
eval "$(sed 's/^\(..*\)$/export \1/'</etc/environment)"
fi
which basically prepends "export " to every non-empty line from
/etc/environment before evaluating them, and it works like a charm.
You can probably do something similar for the csh shells.
This modification pertains to the environment initialization in
/etc/X11/Xsession as well.
Note that adding the export keyword to /etc/environment itself is not
a good idea since you will end up with variables with names like
"export PATH" and "export LESS" when logging in via ssh.
Unless a better solution can be found (or has been found for the
potato base system, I haven't checked recently), I propose that my
solution or something functionally equivalent be used in the default
/etc/profile, /etc/X11/Xsession, and csh initialization scripts in
potato. This will allow the system administrator to set all
system-wide environment variables in one place.
--
#!/usr/bin/perl -w
for(0..12){$b[$_]="|".($_==6?"-":" ")x78}for(0..78){substr($b[-
(sin($_*3.1415/22)-1)*6.499],$_,1)="*"}print join "\n",@b,"";
Reply to: