/bin/sh does not read profile
Polytropon
freebsd at edvax.de
Thu Mar 5 15:40:11 PST 2009
Good evening Betram et al.
I've read the discussion thread as far as it went and would like
to share my own solution to a similar problem, mapped onto the
sh topic. Maybe it works.
A little background:
First of all, because my standard dialog shell is the system's
C shell, the files important are /etc/cshrc with the settings,
such as setenv, alias and path, furthermore /etc/csh.login to
be executed after login, and /etc/csh.logout, executed after
logout. Local to the user exist ~/.cshrc, ~/.login and ~/.logout
which are used if present.
In order to make X work properly with these settings, I have
a kind of "two stages mechanism" which consists of the files
~/.xinitrc and ~/.xsession. The first one is used by X (xdm)
to determine what to do after successful user login, e. g.
start some programs and then exec the window manager / desktop
environment.
Note that both files are chmodded executable:
% ll .xsession .xinitrc
-rwxr-xr-x 1 poly pgm 807 Mar 3 02:46 .xinitrc*
-rwxr-xr-x 1 poly pgm 43 Apr 27 2006 .xsession*
The ~/.xsession doesn't do anything besides first incorporate
settings from ~/.cshrc and then execute ~/.xinitrc.
#!/bin/csh
source ~/.cshrc
exec ~/.xinitrc
It is shebanged with the shell I want to use, which is the C shell.
If ~/.xsession is called, it's last action is to execute ~/.xinitrc.
If ~/.xsession is NOT called, ~/.xinitrc will be executed anyway.
It does the following:
#!/bin/sh
[ -f ~/.xmodmaprc ] && xmodmap ~/.xmodmaprc
xrandr --size 1400x1050 &
xrandr --fb 1400x1050 &
xsetroot -solid rgb:3b/4c/7a
# ... your initializations 'n stuff here ...
exec wmaker
Note that this script is shebanged for sh again. Any X terminals
started now (with csh inside) have the settings from ~/.cshrc.
Mapped onto the initial sh problem, I'd suggest to create the
two files mentioned as follows:
~/.xsession:
#!/bin/sh
[ -f ~/.shrc ] && . ~/.shrc
[ -f ~/.profile ] && . ~/.profile
exec ~/.xinitrc
~/.xinitrc:
#!/bin/sh
[ -f ~/.shrc ] && . ~/.shrc
[ -f ~/.profile ] && . ~/.profile
my_init_stuff_1
my_init_stuff_2
my_init_stuff_3
exec my_wm_startup
Now any instance of sh started should be aware of the settings.
Finally, please note that I'm not a guru for sh (or bash) because
I do use sh only for scripting, and bash never. :-)
--
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions
mailing list