LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bashrc (https://www.linuxquestions.org/questions/linux-newbie-8/bashrc-896576/)

ebbs 08-10-2011 10:59 AM

bashrc
 
Hi,
I'm totally out of my element.
The same user can log in and get a perfect screen on one port and log in to another port and the screen is bad.
Is there anything in this .bashrc file that would cause that to happen? Any help is greatly appreciated.

[root@kw12 niki]# cat /etc/bashrc
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 000
else
umask 000
fi

# are we an interactive shell?
if [ "$PS1" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; e
cho -ne "\007"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -n
e "\033\\"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-
prompt-default
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

if ! shopt -q login_shell ; then # We're not a login shell
# Need to redefine pathmunge, it get's undefined at the end of /etc/profile
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done

unset i
unset pathmunge
fi
# vim:ts=4:sw=4
[root@kw12 niki]#

kbp 08-10-2011 06:03 PM

Just a couple of things .. I don't really like the umask settings, world writable files are bad. Also I can't see what you're doing with PROMPT_COMMAND, you set it but I can't see where you use it...?

It's a lot easier to read code if you put it in a code block like this:

Code:

if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 000
else
    umask 000
fi

<edit>doh .. just realised that PROMPT_COMMAND is supposed to be a variable not executed ... </edit>

grail 08-10-2011 06:57 PM

Could you maybe explain what a 'bad screen' is?

Also, the code that kbp has highlighted is pointless as both true and false entries yield the same thing.
Remove the entire if and just put umask 000 on one line (although I completely agree with kbp that this is a terrible setting)

ebbs 08-11-2011 07:57 AM

A bad screen is where the screen does not draw lines or boxes around the menus. It prints 7 down the sides and ;;;;;; along the bottom. Sorry about the formatting. I did not write it and just did a cut and paste to the post.

A variable not executed??? Please explain.

kbp 08-11-2011 06:39 PM

PROMPT_COMMAND is just an environment variable that's set in bashrc

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html

tommyttt 08-12-2011 02:29 AM

Quote:

The same user can log in and get a perfect screen on one port and log in to another port and the screen is bad.
Is there anything in this .bashrc file that would cause that to happen? Any help is greatly appreciated.
What do you mean by port? Virtual terminal, physical terminal? If physical terminals, it sounds like the ANSI escape characters are not being recognized. Those escape sequences are what tell the terminal how to draw the lines.

Tom


All times are GMT -5. The time now is 06:57 PM.