You are not logged in.
Pages: 1
Hello guys, it is strange that my $HOME/.bashrc is sourced twice whenever a virtual terminal is opened.
There is only .bashrc I'm using, no .bashrc_profile or else. I also check /etc and confirmed the only caller is bash.bashrc. I attach the content of them below:
/etc/bash.bashrc
#
# /etc/bash.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ $DISPLAY ]] && shopt -s checkwinsize
PS1='[\u@\h \W]\$ '
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
;;
screen*)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
;;
esac
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
# source user bashrc
[[ -f ~/.bashrc ]] && . ~/.bashrc
~/.bashrc
echo foobar
I did a test by adding
set -x
in /etc/bash.bashrc just above the line sourcing ~/.bashrc. Then open a v-terminal, i see following output:
+ [[ -f /home/magodo/.bashrc ]]
+ . /home/magodo/.bashrc
++ echo abc
abc
+ echo abc
abc
++ printf '\033]0;%s@%s:%s\007' magodo t460p '~'
[magodo@t460p ~]$
Looks like bash is directly calling the content of ~/.bashrc after sourcing it... I'm confused...
Offline
Does this happen in a TTY? What terminal are you using, and how is it configured?
Offline
Simple: take that line that you added out of /etc/bash.bashrc. Why did you add it in the first place?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Does this happen in a TTY? What terminal are you using, and how is it configured?
I'm using gnome-terminal.
It has no double echo issue if i open TTY.
Simple: take that line that you added out of /etc/bash.bashrc. Why did you add it in the first place?
I add the
set -x
line is only for debugging...
Offline
I meant the line where you source ~/.bashrc.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
@magodo, your /etc/bash.bashrc does not look like "stock" and it should not contain the "[[ -f ~/.bashrc ]] && . ~/.bashrc" line, check
pacman -Qkk bash
Offline
Hi both, thank you!
Offline
Pages: 1