From 5cb934da598d819a6cc2746a8953aaa303ed46df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 13 Feb 2010 00:07:12 +0000 Subject: [PATCH] Fix Bash completion support. svn path=/nixos/trunk/; revision=19971 --- modules/programs/bash/bashrc.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/programs/bash/bashrc.sh b/modules/programs/bash/bashrc.sh index eeecc743c680..6fd7b10f2551 100644 --- a/modules/programs/bash/bashrc.sh +++ b/modules/programs/bash/bashrc.sh @@ -61,11 +61,15 @@ alias ll="ls -l" alias l="ls -alh" alias which="type -p" -# Completion. -#if [ -d "@bash@/etc/bash_completion.d" ]; then -# export BASH_COMPLETION_DIR="@bash@/etc/bash_completion.d" -#fi -#if [ -f "@bash@/etc/bash_completion" ]; then -# export BASH_COMPLETION="@bash@/etc/bash_completion" -# source "$BASH_COMPLETION" -#fi +# The "non-interactive" Bash build does not support programmable +# completion so check whether it's available. +if shopt -q progcomp 2> /dev/null; then + # Completion. + if [ -z "$BASH_COMPLETION_DIR" -a -d "@bash@/etc/bash_completion.d" ]; then + BASH_COMPLETION_DIR="@bash@/etc/bash_completion.d" + fi + if [ -z "$BASH_COMPLETION" -a -f "@bash@/etc/bash_completion" ]; then + BASH_COMPLETION="@bash@/etc/bash_completion" + source "$BASH_COMPLETION" + fi +fi