mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-07-23 15:37:58 +02:00
Some users choose to manage /etc/bash/bashrc directly and disregard any of its updates outright. Additionally, some users have ~/.bashrc as a copy of ${FILESDIR}/bashrc which is either exact or which contains only trivial modifications, meaning that the bashrc.d drop-ins end up being sourced twice. For both of these scenarios, users will presently encounter a diagnostic message indicating that the genfun_has_readline function does not exist. In turn, that is because the function is declared by /etc/bash/bashrc, while also being used by /etc/bash/bashrc.d/10-gentoo-color.bash. Since there is no particular need for 10-gentoo-color.bash to be coupled in this manner, jettison the function. Instead, have bashrc consider the exit status of the "shopt -s no_empty_cmd_completion" command and have 10-gentoo-color.bash perform its own test. Additionally, implement a new bashrc.d drop-in named "15-gentoo-bashrc-check.bash". Its purpose is to check whether ~/.bashrc exists as a copy of ${FILESDIR}/bashrc and instruct the user as to how to remedy the situation. After performing the check, it touches a file under ${TMPDIR} so that it can subsequently avoid driving the user mad. I recommend that this drop-in be removed one year hence. I disliked having to do this but consider it to be in the public interest. Signed-off-by: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/934523 Signed-off-by: Sam James <sam@gentoo.org>
24 lines
1,002 B
Bash
24 lines
1,002 B
Bash
# /etc/bash/bashrc.d/15-gentoo-bashrc-check.bash
|
|
|
|
# Some users have ~/.bashrc as a copy of ${FILESDIR}/bashrc which either matches
|
|
# exactly or is only trivially modified. Such is an improper state of affairs
|
|
# and results in the bashrc.d drop-ins being sourced twice. Warn them that they
|
|
# should use the skeleton file instead. This drop-in should be removed no sooner
|
|
# than one year from the date of its introduction.
|
|
|
|
if [[ -e ${TMPDIR:-/tmp}/.gentoo-bashrc-check-${EUID} || ! -f ~/.bashrc ]]; then
|
|
return
|
|
fi
|
|
|
|
{
|
|
if grep -qxF 'for sh in /etc/bash/bashrc.d/* ; do' -- ~/.bashrc; then
|
|
cat >&3 <<'EOF'
|
|
WARNING! Your ~/.bashrc file is based on an old copy of /etc/bash/bashrc, which
|
|
is not intended for use within a home directory. Please either delete ~/.bashrc
|
|
or replace it with a copy of /etc/skel/.bashrc before optionally customizing it
|
|
further. Neglecting to do so may result in bash behaving unexpectedly.
|
|
|
|
EOF
|
|
fi
|
|
touch -- "${TMPDIR:-/tmp}/.gentoo-bashrc-check-${EUID}"
|
|
} 3>&2 2>/dev/null
|