startwm.sh: make sure sourced scripts are readable

Strictly speaking, both existence and readability should be checked.
However, chances of ~/.profile being a directory or a FIFO are very small
compared to its chances of being non-readable due to some
misconfiguration.

Put "if" and "then" on the same line for consistency with other checks.
Improve comment and pseudocode formatting.
ulab-next-nosound
Pavel Roskin 8 years ago
parent ac901fd283
commit 85840863da

@ -29,36 +29,34 @@ wm_start()
xterm xterm
} }
#Execution sequence for interactive login shell # Execution sequence for interactive login shell - pseudocode
#Following pseudo code explains the sequence of execution of these files. #
#execute /etc/profile # IF /etc/profile is readable THEN
#IF ~/.bash_profile exists THEN # execute ~/.bash_profile
# execute ~/.bash_profile # END IF
#ELSE # IF ~/.bash_profile is readable THEN
# IF ~/.bash_login exist THEN # execute ~/.bash_profile
# execute ~/.bash_login # ELSE
# ELSE # IF ~/.bash_login is readable THEN
# IF ~/.profile exist THEN # execute ~/.bash_login
# execute ~/.profile # ELSE
# END IF # IF ~/.profile is readable THEN
# END IF # execute ~/.profile
#END IF # END IF
# END IF
# END IF
pre_start() pre_start()
{ {
if [ -f /etc/profile ] if [ -r /etc/profile ]; then
then
. /etc/profile . /etc/profile
fi fi
if [ -f ~/.bash_profile ] if [ -r ~/.bash_profile ]; then
then
. ~/.bash_profile . ~/.bash_profile
else else
if [ -f ~/.bash_login ] if [ -r ~/.bash_login ]; then
then
. ~/.bash_login . ~/.bash_login
else else
if [ -f ~/.profile ] if [ -r ~/.profile ]; then
then
. ~/.profile . ~/.profile
fi fi
fi fi
@ -66,15 +64,14 @@ pre_start()
return 0 return 0
} }
#When you logout of the interactive shell, following is the # When loging out from the interactive shell, the execution sequence is:
#sequence of execution: #
#IF ~/.bash_logout exists THEN # IF ~/.bash_logout exists THEN
# execute ~/.bash_logout # execute ~/.bash_logout
#END IF # END IF
post_start() post_start()
{ {
if [ -f ~/.bash_logout ] if [ -r ~/.bash_logout ]; then
then
. ~/.bash_logout . ~/.bash_logout
fi fi
return 0 return 0

Loading…
Cancel
Save