Trying to use /bin/sh

Jilles Tjoelker jilles at stack.nl
Fri Sep 27 22:15:17 UTC 2013


On Fri, Sep 27, 2013 at 12:20:32PM -0700, Sean Bruno wrote:
> I was attempting to simply set my EDITOR env variable for use on my
> system today and discovered that I do *not* understand how computers
> work.

> After realizing that I simply do not understand what's going on, I broke
> down and put an "echo test" into /etc/profile and ~/.profile.

> I can't see why, but logging in via xdm/xfce4 isn't doing any of the
> normal login things and nothing in my .profile is ever executed by any
> shell, ever.

> None of these get executed unless its a login shell.  xfce4 doesn't seem
> to pick these up when starting up, so I have no idea what to do.

> For now, I've put the needed things into a .bashrc and switched my
> loging shell to bash, which is not really what I wanted to do.

sh's model of startup files (only login shells use startup files with
fixed names, other interactive shells only use $ENV) assumes that every
session will load /etc/profile and ~/.profile at some point. This
includes graphical sessions. The ENV file typically contains only shell
options, aliases, function definitions and unexported variables but no
environment variables.

Some graphical environments actually source shell startup files like
~/.profile when logging in. I remember this from CDE for example. It is
important to have some rule where this should happen to avoid doing it
twice or never in "strange" configurations. As a workaround, I made
~/.xsession a script interpreted by my login shell and source some
startup files. A problem here is that different login shells have
incompatible startup files.

A different direction is to accept that the environment variables in the
X session will be incorrect and make all xterms start login shells (e.g.
xterm -ls).

You may also be able to use setenv in ~/.login_conf.

-- 
Jilles Tjoelker


More information about the freebsd-hackers mailing list