# Possible issue in /etc/bashrc?

**URL:** <https://forums.rockylinux.org/t/possible-issue-in-etc-bashrc/16738>\
**Category:** Rocky Linux Help & Support\
**Tags:** rocky-linux-8\
**Created:** [December 4, 2024, 7:15pm UTC](https://forums.rockylinux.org/t/possible-issue-in-etc-bashrc/16738 "2024-12-04T19:15:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierre-rouleau](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@pierre-rouleau](https://forums.rockylinux.org/u/pierre-rouleau)\
**Post date:** [December 4, 2024, 7:15pm UTC](https://forums.rockylinux.org/t/possible-issue-in-etc-bashrc/16738/1 "2024-12-04T19:15:44Z")

</div>

Hi all,

I noticed that the part of **/etc/bashrc** that controls the PATH is doubled sourced event though the file attempts to prevent the double sourcing by checking if the _BASHRCSOURCED_ environment variable is set. if not it sets it but does _not_ export it. The check is therefiore useless and there’s no protection against multiple sourcing it.

The impact is that the PATH grows inside each Bash sub-shell.

The fix is simple, but the location of the check must move, otherwise interactive sub-shells won’t use the same prompt.

My questions:

1. Where is the Git repository where the source of the **/etc/bashrc** is located? It’s probably upstream, right?
2. Where would I find information to report this problem and propose a fix?

For reference, here’s the diff between the original /etc/bashrc on Rocky Linux 8.10 and a version I modified:

```diff
--- bashrc	2024-12-04 11:51:35
+++ new-bashrc	2024-12-04 11:52:05
@@ -8,32 +8,29 @@
 # /etc/profile.d/ to make custom changes to your environment, as this
 # will prevent the need for merging in future updates.
 
-# Prevent doublesourcing
-if [-z "$BASHRCSOURCED"]; then
- BASHRCSOURCED="Y"
 
- # are we an interactive shell?
- if ["$PS1"]; then
+# are we an interactive shell?
+if ["$PS1"]; then
     if [-z "$PROMPT_COMMAND"]; then
- case $TERM in
- xterm*|vte*)
- if [-e /etc/sysconfig/bash-prompt-xterm]; then
- PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
- else
- PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
- fi
- ;;
- screen*)
- if [-e /etc/sysconfig/bash-prompt-screen]; then
- PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
- else
- PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
- fi
- ;;
- *)
- [-e /etc/sysconfig/bash-prompt-default] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
- ;;
- esac
+ case $TERM in
+ xterm*|vte*)
+ if [-e /etc/sysconfig/bash-prompt-xterm]; then
+ PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
+ else
+ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
+ fi
+ ;;
+ screen*)
+ if [-e /etc/sysconfig/bash-prompt-screen]; then
+ PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
+ else
+ PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
+ fi
+ ;;
+ *)
+ [-e /etc/sysconfig/bash-prompt-default] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
+ ;;
+ esac
     fi
     # Turn on parallel history
     shopt -s histappend
@@ -48,8 +45,13 @@
     # PS1="[\u@\h:\l \W]\\$ "
     # fi
     # to your custom modification shell script in /etc/profile.d/ directory
- fi
+fi
 
+# Prevent doublesourcing
+if [-z "$BASHRCSOURCED"]; then
+ BASHRCSOURCED="Y"
+ export BASHRCSOURCED
+
   if ! shopt -q login_shell ; then # We're not a login shell
     # Need to redefine pathmunge, it gets undefined at the end of /etc/profile
     pathmunge () {

```

---

<div class="post-metadata">

**Author:** ![pierre-rouleau](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@pierre-rouleau](https://forums.rockylinux.org/u/pierre-rouleau)\
**Post date:** [December 4, 2024, 7:33pm UTC](https://forums.rockylinux.org/t/possible-issue-in-etc-bashrc/16738/2 "2024-12-04T19:33:32Z")

</div>

I did a little more digging, from Rocky Linux 8.4:

- `rpm -qf /etc/bashrc` identifies the package that provides **/etc/bashrc** : **setup-2.12.2-11.el8.noarch**
- `rpm -qi setup` provides a stale URL (`https://pagure.io/setup/`) that has been replaced by `https://src.fedoraproject.org/rpms/setup`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [February 2, 2025, 7:34pm UTC](https://forums.rockylinux.org/t/possible-issue-in-etc-bashrc/16738/3 "2025-02-02T19:34:24Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
