[Bash-completion-devel] Bug#857235: bash-completion: /etc/profile.d/bash_completion.sh can't be forcibly re-run
Stephen Dowdy (resonance)
sdowdy at ucar.edu
Thu Mar 9 00:33:11 UTC 2017
Package: bash-completion
Version: 1:2.1-4
Severity: normal
Dear Maintainer,
For my root .bashrc i have the following introduction block that is designed to help ensure i don't inherit bad/unexpected values from somewhere else (sshd, /etc/profile.d/, etc...) and the root interactive bash environment is as close to pristine/expected and built on from there.
\unset -f unalias ; \unalias -a ; \unset -f command
\unset LD_LIBRARY_PATH LD_PRELOAD SHELLOPTS CDPATH HISTFILE HOSTFILE INPUTRC 2>/dev/null
confpath="$(command -p getconf PATH 2>/dev/null)"
export PATH="/opt/sbin:/opt/bin:/sbin:/usr/sbin:${confpath:-/bin:/usr/bin}"
\type typeset >/dev/null && \unset -f $(\typeset -f | \grep '()' | \cut -d' ' -f1)
However, because the bash completions package defines a bunch of functions (that i'm removing above), i would like to be able to subsequently re-evaluate the bash completions later on in the .bashrc after this block.
but, /etc/profile.d/bash_completions.sh has the following conditional:
# Check for interactive bash and that we haven't already been sourced.
if [ -n "$BASH_VERSION" -a -n "$PS1" -a -z "$BASH_COMPLETION_COMPAT_DIR" ]; then
Since
/usr/share/bash-completion/bash_completion
establishes BASH_COMPLETION_COMPAT_DIR as a readonly variable, i can not unset it in the shell, and thus can not re-source this script.
I presume it's readonly for security reasons (so it couldn't be hijacked to run random code in another location?)
So, with that in mind, could the conditional be changed instead to something like:
if [ -n "$BASH_VERSION" -a -n "$PS1" -a \( -z "$BASH_COMPLETION_COMPAT_DIR" -o \( "$1" = "force" \) \) ]; then
so that it could be forcibly re-evaluated? (this way i don't have to duplicate its code in my .bashrc and hope it doesn't change on package updates)
Alternative solutions welcome.
thanks,
--stephen
-- System Information:
Debian Release: 8.7
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages bash-completion depends on:
ii bash 4.3-11+deb8u1
ii dpkg 1.17.27
bash-completion recommends no packages.
bash-completion suggests no packages.
-- no debconf information
More information about the Bash-completion-devel
mailing list