[Bug 663111] Re: bash_completion script errors: undefined variables, failed GLOB

daisy stanton 663111 at bugs.launchpad.net
Thu Aug 21 14:06:33 UTC 2014


Does anyone have a workaround for this?

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/663111

Title:
  bash_completion script errors: undefined variables, failed GLOB

Status in “bash-completion” package in Ubuntu:
  Confirmed

Bug description:
  Binary package hint: bash-completion

  The main /etc/bash_completion script and many of the helper scripts
  under /etc/bash_completion.d/ fail for shells running with one or both
  of "set -o nounset" (fail if variables are used without being defined)
  and/or "shopt -s failglob" (fail if a GLOB pattern fails to match).
  I run my interactive shells with both these options set.

  For example:

  bash$ set -o nounset
  bash$ source /etc/bash_completion.ORIG
  bash: BASH_COMPLETION_DEBUG: unbound variable
  bash: BASH_COMPLETION: unbound variable
  bash: BASH_COMPLETION_DIR: unbound variable
  bash: BASH_COMPLETION_COMPAT_DIR: unbound variable
  bash: BASH_COMPLETION: unbound variable
  bash: list[@]: unbound variable
  bash: BASH_COMPLETION_COMPAT_DIR: unbound variable
  bash: BASH_COMPLETION_DIR: unbound variable
  bash: BASH_COMPLETION: unbound variable

  Also, a few of the "eval" expressions in the scripts use backslashes
  but fail to fully protect square bracket characters on arrays, which
  are then taken as failed GLOB expressions.

  The attached patch fixes at least some of the problems with the main
  script so that it runs without error for shells using "set -o nounset"
  and "shopt -s failglob".

  The helper scripts for findutils and mutt in /etc/bash_completion.d/
  also have errors when used in shells using "set -o nounset" and "shopt
  -s failglob", but I'm not so confident that I understand them to fix
  them correctly.  Here are some patches that remove some of the errors
  in these scripts but don't seem to fully work properly:

  --- .findutils.ORIG	2010-08-06 19:39:13.000000000 -0400
  +++ findutils	2010-10-18 11:52:07.982166655 -0400
  @@ -5,7 +5,7 @@
   have find &&
   _find()
   {
  -    local cur prev i exprfound onlyonce
  +    local cur prev i exprfound= onlyonce
   
       COMPREPLY=()
       _get_comp_words_by_ref cur prev

  
  --- .mutt.ORIG	2010-08-06 19:39:13.000000000 -0400
  +++ mutt	2010-10-12 11:23:48.717163963 -0400
  @@ -22,6 +22,7 @@
   _muttrc()
   {
       # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument
  +    local muttrc=
       set -- "${COMP_WORDS[@]}"
       while [ $# -gt 0 ]; do
           if [ "${1:0:2}" = -F ]; then
  @@ -55,13 +56,14 @@
   
       sofar=" $1 "
       shift
  -    while [[ "$1" ]]; do
  -        newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) )
  -        for file in "${newconffiles[@]}"; do
  +    while [[ $# -gt 0 && "$1" ]]; do
  +        newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$1" ) )
  +        for file in "${newconffiles[@]-}"; do
               [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
                   continue
               sofar="$sofar $file"
  -            sofar=" $(eval _muttconffiles \"$sofar\" $file) "
  +            sofar=$(_muttconffiles "$sofar" "$file")
           done
           shift
       done
  @@ -80,8 +82,8 @@
   
       conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
       aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
  -        $(eval echo "${conffiles[@]}") ) )
  -    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- "$cur" ) )
  +        $(eval echo "${conffiles[@]:-/dev/null}") ) )
  +    COMPREPLY=( "${COMPREPLY[@]-}" $( compgen -W "${aliases[*]-}" -- "$cur" ) )
   
       return 0
   }
  @@ -101,7 +103,7 @@
               sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ) )
       fi
   
  -    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
  +    COMPREPLY=( "${COMPREPLY[@]-}" $( compgen -W "${queryresults[*]-}" \
           -- "$cur" ) )
   
       return 0

  ProblemType: Bug
  DistroRelease: Ubuntu 10.10
  Package: bash-completion 1:1.2-2ubuntu1
  ProcVersionSignature: Ubuntu 2.6.35-22.34-generic 2.6.35.4
  Uname: Linux 2.6.35-22-generic x86_64
  Architecture: amd64
  Date: Tue Oct 19 02:08:30 2010
  EcryptfsInUse: Yes
  InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64 (20101007)
  PackageArchitecture: all
  ProcEnviron:
   LC_CTYPE=en_CA.utf8
   LC_COLLATE=C
   PATH=(custom, user)
   LANG=C
   SHELL=/bin/bash
  SourcePackage: bash-completion

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/663111/+subscriptions



More information about the foundations-bugs mailing list