You are not logged in.

#1 2011-05-09 10:44:50

archnet
Member
Registered: 2011-05-09
Posts: 42

[SOLVED] bash and xterm - which files get read and referenced?

I currently have my user shell set as /bin/sh (which, as I'm sure you are aware, is a symlink to bash). When I launch xterm, none of my config files seem to be read or sourced. If I login from the console, all is correct.

According to the documentation I've read, when bash is invoked as sh, it should read /etc/profile, and then .profile, and finally .shrc (which is recommended to be explicitly sourced from .profile). I can see that /etc/profile is being read, as the PATH is being updated from items in /etc/profile.d, but none of my config files in ~ are being read.

I put in a unique alias in each of .bash_profile, .bashrc, .profile, and .shrc to try to trace the files being read. In console, this reveals that .profile and .shrc are being read (as I would expect). But, in xterm, no aliases are being read.

Also, PS1 is set to sh-4.2$ (literally set as '\s-\v\$ '). I have tried to grep that sequence in /etc, but that failed to hit on anything.

I don't have my own .Xresources and nothing in .xinitrc redefines xterm behavior. The only switches I am explicitly sending to xterm redefine appearance (background/foreground color and font).

The only other relevant piece of information I can think of is that I am using the slim login manager and in slim.conf it defines: login_cmd exec /bin/bash -login ~/.xinitrc %session. I changed that to /bin/sh, but it had no effect.

Any ideas?

Solution
Adding

XTerm*.LoginShell: True

to ~/.Xdefaults will cause xterm to behave as expected.

Last edited by archnet (2011-05-11 00:40:49)

Offline

#2 2011-05-09 10:48:30

neurolysis
Member
Registered: 2011-02-23
Posts: 112
Website

Re: [SOLVED] bash and xterm - which files get read and referenced?

xterm will read ~/.bashrc, since it isn't a login shell.

Source ~/.bashrc from ~/.bash_profile, and put the stuff you want in ~/.bashrc.

Offline

#3 2011-05-09 11:20:51

archnet
Member
Registered: 2011-05-09
Posts: 42

Re: [SOLVED] bash and xterm - which files get read and referenced?

neurolysis wrote:

xterm will read ~/.bashrc, since it isn't a login shell.

Source ~/.bashrc from ~/.bash_profile, and put the stuff you want in ~/.bashrc.

That was one of the first things I tried. I even tried using the absolute path. But, that did not work.

Offline

#4 2011-05-09 12:58:32

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [SOLVED] bash and xterm - which files get read and referenced?

Is $HOME set?
If not, try logging on without slim and testing $HOME then. If it's okay, it could be slim.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#5 2011-05-09 15:15:11

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: [SOLVED] bash and xterm - which files get read and referenced?

To answer your actual question:

strace -eopen xterm
strace -eopen sh

Offline

#6 2011-05-09 21:30:24

archnet
Member
Registered: 2011-05-09
Posts: 42

Re: [SOLVED] bash and xterm - which files get read and referenced?

skanky wrote:

Is $HOME set?
If not, try logging on without slim and testing $HOME then. If it's okay, it could be slim.

$HOME is properly set.

Offline

#7 2011-05-09 21:44:17

archnet
Member
Registered: 2011-05-09
Posts: 42

Re: [SOLVED] bash and xterm - which files get read and referenced?

dmz wrote:

To answer your actual question:

strace -eopen xterm
strace -eopen sh

Here is the output:

sh-4.2$ strace -eopen xterm
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/usr/lib/libXft.so.2", O_RDONLY)  = 3
open("/usr/lib/libXaw.so.7", O_RDONLY)  = 3
open("/lib/libncursesw.so.5", O_RDONLY) = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/usr/lib/libfontconfig.so.1", O_RDONLY) = 3
open("/usr/lib/libX11.so.6", O_RDONLY)  = 3
open("/usr/lib/libXmu.so.6", O_RDONLY)  = 3
open("/usr/lib/libXt.so.6", O_RDONLY)   = 3
open("/usr/lib/libICE.so.6", O_RDONLY)  = 3
open("/usr/lib/libfreetype.so.6", O_RDONLY) = 3
open("/usr/lib/libXrender.so.1", O_RDONLY) = 3
open("/usr/lib/libXext.so.6", O_RDONLY) = 3
open("/usr/lib/libXpm.so.4", O_RDONLY)  = 3
open("/usr/lib/libz.so.1", O_RDONLY)    = 3
open("/usr/lib/libexpat.so.1", O_RDONLY) = 3
open("/usr/lib/libxcb.so.1", O_RDONLY)  = 3
open("/lib/libdl.so.2", O_RDONLY)       = 3
open("/usr/lib/libSM.so.6", O_RDONLY)   = 3
open("/usr/lib/libXau.so.6", O_RDONLY)  = 3
open("/usr/lib/libXdmcp.so.6", O_RDONLY) = 3
open("/lib/libuuid.so.1", O_RDONLY)     = 3
open("/proc/meminfo", O_RDONLY)         = 3
open("/home/archnet/.Xauthority", O_RDONLY) = 4
open("/home/archnet/.Xdefaults", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/locale-archive", O_RDONLY) = 4
open("/usr/share/X11/locale/locale.alias", O_RDONLY) = 4
open("/usr/share/X11/locale/locale.alias", O_RDONLY) = 4
open("/usr/share/X11/locale/locale.dir", O_RDONLY) = 4
open("/usr/share/X11/locale/en_US.UTF-8/XLC_LOCALE", O_RDONLY) = 4
open("/home/archnet/.Xdefaults-natoufa", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.Xdefaults", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/X11/app-defaults/XTerm", O_RDONLY) = 4
open("/etc/ld.so.cache", O_RDONLY)      = 4
open("/usr/lib/libXcursor.so.1", O_RDONLY) = 4
open("/usr/lib/libXfixes.so.3", O_RDONLY) = 4
open("/home/archnet/.icons/default/cursors/xterm", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/xterm", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/xterm", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_v_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_v_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_v_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_h_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_h_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_h_double_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_up_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_up_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_up_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_down_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_down_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_down_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_left_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_left_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_left_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/cursors/sb_right_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/archnet/.icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/cursors/sb_right_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/icons/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/cursors/sb_right_arrow", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/pixmaps/default/index.theme", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/dev/tty", O_RDWR)                = 4
open("/dev/ptmx", O_RDWR)               = 4
open("/home/archnet/.XCompose", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/X11/locale/compose.dir", O_RDONLY) = 5
open("/usr/share/X11/locale/en_US.UTF-8/Compose", O_RDONLY) = 5
open("/usr/share/X11/XKeysymDB", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/gconv/gconv-modules", O_RDONLY) = 5
open("/usr/share/terminfo/x/xterm", O_RDONLY) = 5
sh-4.2$ strace -eopen sh
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libreadline.so.6", O_RDONLY) = 3
open("/lib/libncursesw.so.5", O_RDONLY) = 3
open("/lib/libdl.so.2", O_RDONLY)       = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/dev/tty", O_RDWR|O_NONBLOCK)     = 3
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
open("/proc/meminfo", O_RDONLY)         = 3
open("/etc/nsswitch.conf", O_RDONLY)    = 3
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libnss_files.so.2", O_RDONLY) = 3
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/gconv/gconv-modules", O_RDONLY) = 3
open("/home/archnet/.bash_history", O_RDONLY) = 3
open("/home/archnet/.bash_history", O_RDONLY) = 3
open("/usr/share/terminfo/x/xterm", O_RDONLY) = 3
open("/etc/inputrc", O_RDONLY)          = 3

I don't see it attempting to read any sort of profile for shrc file.

Offline

#8 2011-05-09 22:37:58

archnet
Member
Registered: 2011-05-09
Posts: 42

Re: [SOLVED] bash and xterm - which files get read and referenced?

Ok, I found something out. Going to the console, after logging in if I invoke sh I get the same issues, nothing loads correctly. However, if I force it to be a login shell (i.e., sh -login), then the expected files are properly read and all is well.

So, from this I would assume the problem is that when xterm gets called, it doesn't invoke my shell as a login shell.

To solve this, I created a ~/.Xdefaults with the following line:

XTerm*.LoginShell: True

If anyone knows of a simpler method that doesn't involve maintaining yet another file, I'm all ears.

Thanks for all the hints.

Offline

Board footer

Powered by FluxBB