From: W. Trevor King Date: Thu, 1 Dec 2011 13:50:36 +0000 (-0500) Subject: Avoid sourcing /etc/bash_completion twice for Debian-based distributions. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a29abad5007858df59160ac5d0b88eb449ae0a3e;p=dotfiles-public.git Avoid sourcing /etc/bash_completion twice for Debian-based distributions. On a system running Debian 5.0 (Lenny), running /etc/bash_completion once sets some variables (e.g. BASH_COMPLETION) and then makes them read-only. Running /etc/bash_completion again raises errors when it tries to reset these read-only variables, and the script bails, taking down all subsequent .bashrc processing with it. Work around this problem by only sourcing /etc/bash_completion if the BASH_COMPLETION variable is empty. Later versions of /etc/bash_completion avoid this issue by only setting the variables if they are empty. Versions affected: Debian 5.0 (Lenny) running /etc/bash_completion 20060301 Ubuntu 8.04.4 running /etc/bash_completion 20060301 Versions not affected: Ubuntu 9.04 running /etc/bash_completion 20080617.5 Ubuntu 10.04.2 running /etc/bash_completion 1.1 (2009) Ubuntu 10.04.3 running /etc/bash_completion 1.1 (2009) The fix should work with all the versions I've seen. --- diff --git a/src/.bashrc.d/20completion b/src/.bashrc.d/20completion index 0c50784..b99ebd9 100644 --- a/src/.bashrc.d/20completion +++ b/src/.bashrc.d/20completion @@ -20,7 +20,7 @@ elif [ "${OS}" = 'Debian' ] || [ "${OS}" = 'Ubuntu' ]; then # /etc/bash_completion # You won't need to enable this if you uncommented the appropriate # section in /etc/bash.bashrc. - if [ -f /etc/bash_completion ]; then + if [ -f /etc/bash_completion ] && [ -z "${BASH_COMPLETION}" ]; then . /etc/bash_completion fi fi