[Bash-completion-devel] Bug#578423: bash-completion: uses declare -r instead of set + readonly in /etc/bash_completion
Julian Gilbey
jdg at debian.org
Mon Apr 19 18:42:54 UTC 2010
Package: bash-completion
Version: 1:1.1-3
Severity: normal
Tags: patch
Please apply the patch below. The problem is that declare has a nasty
side-effect: it make variables local if they are called from within a
function. I source my /etc/bash_completion in my .bashrc as:
sourceif() { test -r "$1" && . "$1"; }
[...]
sourceif /etc/bash_completion
meaning that if I move to a machine without bash-completion installed,
my profile will still work.
However, this means that bash4 is made local to the function, and
hence completion fails on filenames with spaces, as bash4 is unset by
the time the test is used.
This patch makes the bash* variables readonly without using the
localising declare function.
Julian
--- /etc/bash_completion.orig 2010-04-19 21:32:50.000000000 +0300
+++ /etc/bash_completion 2010-04-19 21:37:43.000000000 +0300
@@ -59,7 +59,8 @@
# features supported by bash 2.05 and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
- declare -r bash205=$BASH_VERSION 2>/dev/null || :
+ bash205=$BASH_VERSION
+ readonly bash205
default="-o default"
dirnames="-o dirnames"
filenames="-o filenames"
@@ -68,18 +69,21 @@
# features supported by bash 2.05b and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
- declare -r bash205b=$BASH_VERSION 2>/dev/null || :
+ bash205b=$BASH_VERSION
+ readonly bash205b
nospace="-o nospace"
fi
# features supported by bash 3.0 and higher
if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
- declare -r bash3=$BASH_VERSION 2>/dev/null || :
+ bash3=$BASH_VERSION
+ readonly bash3
bashdefault="-o bashdefault"
plusdirs="-o plusdirs"
fi
# features supported by bash 4.0 and higher
if [ ${BASH_VERSINFO[0]} -gt 3 ]; then
- declare -r bash4=$BASH_VERSION 2>/dev/null || :
+ bash4=$BASH_VERSION
+ readonly bash4
compopt=compopt
fi
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages bash-completion depends on:
ii bash 4.1-2 The GNU Bourne Again SHell
bash-completion recommends no packages.
bash-completion suggests no packages.
-- no debconf information
More information about the Bash-completion-devel
mailing list