BASH invocation on Sab. . .

Discussion in general that pertains to Sabayon Linux - Must Pertain to Sabayon Linux

Moderator: Moderators

Post Reply
Simple Hen
Posts: 75
Joined: Wed Sep 06, 2006 15:08
Location: Denmark

BASH invocation on Sab. . .

Post by 2ny » Mon Mar 24, 2008 10:22


I am trying to figure out why, if I insert a command in ~/.bashrc or ~/.profile to run 'xscreensaver' at log-in - as would be pretty much standard in every other Linux I know of, every time I exit a konsole instance (even shutting off the PC!) or attempting to start a new instance of the konsole, xscreensaver is trying to start a new instance of itself and naturally protests about it.

The Bash documentation has this to say:

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files. When invoked as sh, bash enters posix mode after the startup files are read.

When bash is started in posix mode, as with the --posix command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

Bash attempts to determine when it is being run by the remote shell daemon, usually rshd. If bash determines it is being run by rshd, it reads and executes commands from ~/.bashrc, if that file exists and is readable. It will not do this if invoked as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be used to force another file to be read, but rshd does not generally invoke the shell with those options or allow them to be specified.


Can anyone reveal how Bash is being invoked from the Sabayon start-up scripts, [or/and] tell me how I am supposed to handle such individual requirements as writing your own personalization scripts and 'Aliases', and possibly where I should be putting those in the first place?


Tony. . .

Baby Hen
Posts: 4
Joined: Mon Mar 24, 2008 16:15

Re: BASH invocation on Sab. . .

Post by Mr_Qwerty » Mon Mar 24, 2008 16:24

Normally, you'd put X-specific starting code in a file called "/etc/xprofile" or in "$HOME/.xprofile"; the first being global and the second, user-specific. Notice that in many distributions (Sabayon is obviously not an exception) this file does not exist, and you will have to create it. It is sourced by the standard "startx" script that comes with the X server and most display managers; if not, you should add to it or consult the documentation of your display manager on how to add it.

P.S.: If xprofile isn't being sourced for whatever reason and you just want it working NOW, you can add to your .profile/.bashrc/etc.:

Code: Select all

ps -A > ~/txt.txt
if grep xscreensaver ~/txt.txt
    rm ~/txt.txt
    rm ~/txt.txt
Not elegant at all, but will do the trick.

Old Dear Hen
Posts: 742
Joined: Mon Jul 09, 2007 20:29
Location: Mobile, AL, USA

Re: BASH invocation on Sab. . .

Post by DontPanic » Tue Mar 25, 2008 19:55

Thanks for the tip on .xprofile. I've been putting my commands in .xinitrc and .xsession, only to have kdm skip right by them.

When formulating a bash command to look at the running processes, I usually use something like:

Code: Select all

if ( ! ps axw | grep xscreensaver | grep -v grep ); then
   /usr/bin/xscreensaver &
The first pass through, grep will usually find itself looking for xscreensaver, as well as finding any instances of xscreensaver. The second 'grep -v grep' pass rejects the lines that have 'grep' in them, and kicks out the occurance of grep itself.
Gigabyte GA-P35-DS3L - Intel(R) Core(TM)2 Duo CPU [email protected] 2.66GHz
nVidia GeForce 7600 GS

Post Reply