You are not logged in.

#1 2011-02-14 04:27:22

siavashserver
Member
Registered: 2011-02-11
Posts: 73

[SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Hi, after a daily pacman -Syu and updating the bash, i got a new pacnew. I'm not sure which parts should I merge, just wondering how to merge these guys :


/etc/bash.bashrc :

#
# /etc/bash.bashrc
#
# This file is the systemwide bashrc file. While most of the
# environment is preserved when running an interactive shell
# the PS[1-4] variables, aliases and functions are reset.
#
# When running a non-login shell, apply the following settings:
# - Prompt defaults (PS[1-4], PROMPT_COMMAND)
# - bash_completion if it exists
# - source /etc/bash.bashrc.local

PS1='[\u@\h \W]\$ '
PS2='> '
PS3='> '
PS4='+ '

export PS1 PS2 PS3 PS4

if test "$TERM" = "xterm" -o \
        "$TERM" = "xterm-color" -o \
        "$TERM" = "xterm-256color" -o \
        "$TERM" = "rxvt" -o \
        "$TERM" = "rxvt-unicode" -o \
        "$TERM" = "xterm-xfree86"; then
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
    export PROMPT_COMMAND
fi

[ -r /etc/bash_completion   ] && . /etc/bash_completion
[ -r /etc/bash.bashrc.local ] && . /etc/bash.bashrc.local

/etc/bash.bashrc.pacnew

#
# /etc/bash.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '
PS2='> '
PS3='> '
PS4='+ '

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 /etc/bash_completion   ] && . /etc/bash_completion

Regards, Siavash.

Last edited by siavashserver (2011-02-14 05:31:51)

Offline

#2 2011-02-14 04:34:56

lagagnon
Member
From: an Island in the Pacific...
Registered: 2009-12-10
Posts: 1,087
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew


Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.

Offline

#3 2011-02-14 04:46:46

siavashserver
Member
Registered: 2011-02-11
Posts: 73

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Thanks for the link, but I know how to merge them with Meld and I read that wiki page before.

I don't like to merge everything blindly, because last time made me to reset root password. I want to make sure that is it safe to completely replace the old one with the new one?

Last edited by siavashserver (2011-02-14 04:48:43)

Offline

#4 2011-02-14 05:11:29

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Hmm, I got a pacnew for that file as well and I've never edited it. It looks to be safe to replace the old with the new.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#5 2011-02-14 06:39:54

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Basically: If you changed anything to the base file of a  .pacnew file - compare, understand the proposed changes and only then merge. If there is any doubt about what happend, ask (to the point, please).

If there was no change to the old files it might be safe to simply replace the old one with the .pacnew.

In any case: Backup your old files, by e.g. copying your old <file> over to <file>.old, before you touch anything.

Last edited by bernarcher (2011-02-14 06:40:55)


To know or not to know ...
... the questions remain forever.

Offline

#6 2011-02-21 17:37:45

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Hey, I just did that update, and noticed that "/etc/bash.bashrc.local" is no longer executed... I was using that file to create my aliases. Is there another file that can be used for that purpose? (aliases that would work for all users.)

Offline

#7 2011-02-21 19:49:16

siavashserver
Member
Registered: 2011-02-11
Posts: 73

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

I think you have forgotten to keep the last line of your original "/etc/bash.bashrc" which I believe executes "/etc/bash.bashrc.local", correct me please if I'm wrong. BTW, here is mine after merging :

#
# /etc/bash.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '
PS2='> '
PS3='> '
PS4='+ '

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 /etc/bash_completion   ] && . /etc/bash_completion
[ -r /etc/bash.bashrc.local ] && . /etc/bash.bashrc.local

Offline

#8 2011-02-21 20:06:12

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

siavashserver wrote:

I think you have forgotten to keep the last line of your original "/etc/bash.bashrc" which I believe executes "/etc/bash.bashrc.local"

Well, yes... It is my understanding that that line was here to enable end-users to add things to their global bashrc without modifying /etc/bash.bashrc (thus not having to merge stuff at each update.) So I'm wondering why it was removed, and if there is an alternative mecanism in place to do the same thing.

Edit: in the meanwhile, I'll do like you and add it back...

Last edited by stqn (2011-02-21 20:08:16)

Offline

#9 2011-03-06 00:58:22

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

What exactly does the following code do:

[[ $- != *i* ]] && return

?


joe@trusktr.io - joe at true skater dot io.

Offline

#10 2011-03-06 01:05:06

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Exactly what the line above it documents it doing...

Offline

#11 2011-03-06 01:24:25

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

Can you briefly explain the syntax?


joe@trusktr.io - joe at true skater dot io.

Offline

#12 2011-03-06 01:46:56

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] Merging bash.bashrc and bash.bashrc.pacnew

I had a look at bash's man page and while not extremely clear at first sight, I could find this information:

OPTIONS wrote:

       -i        If the -i option is present, the shell is interactive.

Special Parameters wrote:

       -      Expands  to  the  current option flags as specified upon invoca‐
              tion, by the set builtin command, or  those  set  by  the  shell
              itself (such as the -i option).

... So my guess is that if $- contains i, then the shell is interactive.

Offline

Board footer

Powered by FluxBB