Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reading /etc/profile on graphical terminals

0 views
Skip to first unread message

Bruno de Oliveira Schneider

unread,
Apr 17, 2006, 10:00:18 AM4/17/06
to
Hi, there is an active discussion topic at debian-user-portuguese
mailing list, where some people are stating that /etc/profile is
sourced upon activation of a X session.

They say that by adding "export SOME_BOGUS_VAR=some_value" in
/etc/profile, the bogus var should be set when any graphical terminal
(such as xterm, konsole, gnome-terminal, etc.) is opened. The reason
for that would be that when a X session is opened, a pseudo-terminal in
/dev/pts/n is opened as a login shell.

However, this doesn't make much sense to me, and it doesn't work on my
Debian box. If I want to achieve something like that, I must add the
bogus variable to /etc/bash.bashrc.

Perhaps someone here could help come to a conclusion as to whether one
should expect /etc/profile to be sourced on graphical terminals.

--
Bruno de Oliveira Schneider

Chris F.A. Johnson

unread,
Apr 17, 2006, 5:01:56 PM4/17/06
to
On 2006-04-17, Bruno de Oliveira Schneider wrote:
> Hi, there is an active discussion topic at debian-user-portuguese
> mailing list, where some people are stating that /etc/profile is
> sourced upon activation of a X session.
>
> They say that by adding "export SOME_BOGUS_VAR=some_value" in
> /etc/profile, the bogus var should be set when any graphical terminal
> (such as xterm, konsole, gnome-terminal, etc.) is opened. The reason
> for that would be that when a X session is opened, a pseudo-terminal in
> /dev/pts/n is opened as a login shell.

Environment variables set in /etc/profile will only be visible to
children of the shell that sourced it. If the script that starts X
(or the shell that is running that script) sources it, then the
variables will be visible to shells started under X.

> However, this doesn't make much sense to me, and it doesn't work on my
> Debian box. If I want to achieve something like that, I must add the
> bogus variable to /etc/bash.bashrc.

That file is not sourced by bash, but by some other script.

> Perhaps someone here could help come to a conclusion as to whether one
> should expect /etc/profile to be sourced on graphical terminals.

If the terminal is opened with bash as a login shell, then it will
be sourced; otherwise it will not.


--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Bruno de Oliveira Schneider

unread,
Apr 18, 2006, 8:11:54 AM4/18/06
to
On 2006-04-17, Bruno de Oliveira Schneider wrote:
>> However, this doesn't make much sense to me, and it doesn't work on my
>> Debian box. If I want to achieve something like that, I must add the
>> bogus variable to /etc/bash.bashrc.

On 2005-04-17, Chris F.A. Johnson wrote:
> That file is not sourced by bash, but by some other script.

That is strange. At my Debian machine, "man bash" says (in Invocation
section):
"When an interactive shell that is not a login shell is
started, bash reads and executes commands from /etc/bash.bashrc and
~/.bashrc, if these files exist."

Are different bash versions with different initialization procedures?
Here is what my bash says about its version:

$ bash --version
GNU bash, version 3.1.0(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Chris F.A. Johnson

unread,
Apr 18, 2006, 1:08:20 PM4/18/06
to
On 2006-04-18, Bruno de Oliveira Schneider wrote:
> On 2006-04-17, Bruno de Oliveira Schneider wrote:
>>> However, this doesn't make much sense to me, and it doesn't work on my
>>> Debian box. If I want to achieve something like that, I must add the
>>> bogus variable to /etc/bash.bashrc.
>
> On 2005-04-17, Chris F.A. Johnson wrote:
>> That file is not sourced by bash, but by some other script.
>
> That is strange. At my Debian machine, "man bash" says (in Invocation
> section):
> "When an interactive shell that is not a login shell is
> started, bash reads and executes commands from /etc/bash.bashrc and
> ~/.bashrc, if these files exist."

Debian distributes a bastardized version of bash. So, for that
matter, do other Linux distros, but Debian seems to be the worst.

I always compile my own bash to be certain of getting standard
behaviour.

> Are different bash versions with different initialization procedures?
> Here is what my bash says about its version:
>
> $ bash --version
> GNU bash, version 3.1.0(1)-release (i486-pc-linux-gnu)
> Copyright (C) 2005 Free Software Foundation, Inc.


--

0 new messages