LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Bash shell being displayed twice? (https://www.linuxquestions.org/questions/linux-from-scratch-13/bash-shell-being-displayed-twice-373192/)

Seph64 10-14-2005 09:28 PM

Bash shell being displayed twice?
 
Err, something like that. I wish I could make the topic more specific

After building LFS, and starting working on the BLFS parts, I rebooted to my LFS base system (after re-building shadow like the book tells me to when I install PAM) in order to login as a different user to test su.

PROBLEM:

It seems my bash shell gets displayed twice, something like this:

seph64@LFS - /home/seph64:seph64@LFS - $:

Any reason why it is doing this, and what configuration file I need to edit to fix it (so far I've done everything the install book told me to)?

Thanks in advance.

Dark_Helmet 10-14-2005 10:34 PM

I'm guessing you messed with ~/.bash_profile or /etc/profile. Check to make sure you didn't make an "oops" when setting the PS1 environment variable.

I would bet money that in one of those files, there's a line containing something like this:
Code:

PS1="$PS1:\u@\h - \$"

Seph64 10-14-2005 10:45 PM

If I find something like that in one of the files specified, I should take out the extra $PS1?

I looked at the /etc/profile and /etc/bashrc

And both has something similar in the export PS1 fields.

Should only one of those files have the export?

Dark_Helmet 10-14-2005 11:19 PM

Yeah, sorry for leaving you hanging... :)

You'd want to remove the $PS1 reference in the assignment. As a safety measure, copy the line, comment the original, make changes to the copy, and see where it gets you. If all's well, delete the original.

If you'd like a second pair of eyes, go ahead and post the contents of both files. I don't think they'd be too terribly long to look at.

EDIT:
I changed the line above to use red text indicating what should probably be removed. By you can play with any of those assignments to suit yourself. Keep in mind that /etc/profile is looked at first, and then ~/.bash_profile. Also, changes you make won't be reflected until you log out, and log back in again.

mr_demilord 10-15-2005 02:42 AM

Thanks, I had the same problem and it's fixed. :cool:

Seph64 10-15-2005 09:01 AM

You mis understood me.

In /etc/profile there was this:

Quote:

export PS1='\u@\h:\w\$ '
That was also in /etc/bashrc, commenting out the line in /etc/bashrc did nothing. And there was nothing like that in ~/.bash_profile

Dark_Helmet 10-15-2005 11:05 AM

No misunderstanding ;)

What I mentioned was a possible explanation, not necessarily the cause of your situation specifically. There's probably still some funny business going on in one of the startup files. If you want to experiment, at a command prompt, type this:
Code:

export PS1='\u@\h:\w\$ '
If executing that command fixes your prompt, then there's something wrong with bash's startup files.You'll have to hunt down where it is. With LFS, the PS1 assignment can be in any number of places: /etc/profile, /etc/bashrc, /etc/profile.d/*, ~/.bash_profile, ~/.bashrc.

Having an identical "export PS1=something" statement in multiple files won't hurt anything, but if the statement had a reference to "$PS1" in the example above, then that's a problem.

If the export command at the prompt doesn't fix your problem, then there is something really strange going on. None of the software in the LFS of BLFS books should mess with the prompt at all. If there's something non-standard that's been installed, that would be a good place to start looking through documentation.

Seph64 10-15-2005 11:17 AM

Nope, doesn't fix the prompt.

I looked through various files (/etc/profile, /etc/profile.d/, and the bash files) I am still puzzled why this problem exists.

I think the problem is with the /etc/profile file. as I have copied the /etc/profile from my gentoo install to the LFS install, and I don't get the problem.

I think I will post the text from the /etc/profile that the BLFS books states.

Code:

root@localhost / # cat /etc/profile.backup
# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>

# System wide environment variables and startup programs.

# System wide aliases and functions should go in /etc/bashrc.  Personal
# environment variables and startup programs should go into
# ~/.bash_profile.  Personal aliases and functions should go into
# ~/.bashrc.

# Functions to help us manage paths.  Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
        local IFS=':'
        local NEWPATH
        local DIR
        local PATHVARIABLE=${2:-PATH}
        for DIR in ${!PATHVARIABLE} ; do
                if [ "$DIR" != "$1" ] ; then
                  NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
                fi
        done
        export $PATHVARIABLE="$NEWPATH"
}

pathprepend () {
        pathremove $1 $2
        local PATHVARIABLE=${2:-PATH}
        export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}

pathappend () {
        pathremove $1 $2
        local PATHVARIABLE=${2:-PATH}
        export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}


# Set the initial path
export PATH=/bin:/usr/bin

if [ $EUID -eq 0 ] ; then
        pathappend /sbin:/usr/sbin
        unset HISTFILE
fi

# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
#export PS1="[\u@\h \w]\\$ "
export PS1='\u@\h:\w\$ '

for script in /etc/profile.d/*.sh ; do
        if [ -r $script ] ; then
                . $script
        fi
done

# Now to clean up
unset pathremove pathprepend pathappend

# End /etc/profile


Dark_Helmet 10-15-2005 12:26 PM

Execute this command at a command prompt:
Code:

grep -lr "PS1" /etc/*
My gut says there will be a file in /etc/profile.d listed. Post those file(s) if they're not too terribly long.

Seph64 10-15-2005 12:29 PM

Nope, only /etc/bashrc and /etc/profile

Dark_Helmet 10-15-2005 12:36 PM

Could you post /etc/bashrc as well?

Seph64 10-15-2005 01:05 PM

Code:

bash-3.00# cat /etc/bashrc
# Begin /etc/bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>

# Make sure that the terminal is set up properly for each shell

if [ -f /etc/profile.d/tinker-term.sh ]; then
  source /etc/profile.d/tinker-term.sh
fi

# System wide aliases and functions.

# System wide environment variables and startup programs should go into
# /etc/profile.  Personal environment variables and startup programs
# should go into ~/.bash_profile.  Personal aliases and functions should
# go into ~/.bashrc

# Provides a colored /bin/ls command.  Used in conjunction with code in
# /etc/profile.

alias ls='ls --color=auto'

# Provides prompt for non-login shells, specifically shells started
# in the X environment. [Review the LFS archive thread titled
# PS1 Environment Variable for a great case study behind this script
# addendum.]

#export PS1="[\u@\h \w]\\$ "
#export PS1='\u@\h:\w\$ '

# End /etc/bashrc

I commented out the last export PS1 thinking it might've been the problem.

Dark_Helmet 10-15-2005 01:14 PM

Honestly, I don't see anything wrong with those files.

If you want to find the culprit, then all I can suggest is start with your Gentoo version of /etc/profile and work your way back toward the LFS /etc/profile. Make a small change and see if it breaks. When/if it does break, it should give some idea where to look next.

Dark_Helmet 10-15-2005 01:22 PM

Whoa, whoa, whoa...

BLFS book, Chapter 3: "After LFS Configuration Issues"

Slightly past the middle of the page it says:
Quote:

/etc/profile.d/extra-prompt.sh

This script shows an example of a different way of setting the prompt. The normal variable, PS1, is supplemented by PROMPT_COMMAND. If set, the value of PROMPT_COMMAND is executed as a command prior to issuing each primary prompt. The sequence \e is an ESC character. \a is a BEL character. For a reference on xterm escape sequences, see http://rtfm.etla.org/xterm/ctlseq.html.

Code:

cat > /etc/profile.d/extra-prompt.sh << "EOF"
PROMPT_COMMAND='echo -ne "\e[1m${USER}@${HOSTNAME} : ${PWD}\e[0m\a"'
export PROMPT_COMMAND
EOF

The escape sequences above are BOLD, NORMAL, and BEL.
Kill that file or rename it to something other than *.sh and see if things improve.

Seph64 10-15-2005 01:28 PM

There's one oddity in all this. If I press up and scroll through the list of commands I used, it'll sometimes show the prompt as it should, but only til the next command.

Doesn't seem like it helps much.

Actually I just exited my chroot and re-entered the chroot, and now it appears to work.

Thanks.


All times are GMT -5. The time now is 12:39 AM.