errors with set -o nounset
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash-completion (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: bash-completion
The main /etc/bash_
under /etc/bash_
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_
bash: BASH_COMPLETION
bash: BASH_COMPLETION: unbound variable
bash: BASH_COMPLETION
bash: BASH_COMPLETION
bash: BASH_COMPLETION: unbound variable
bash: list[@]: unbound variable
bash: BASH_COMPLETION
bash: BASH_COMPLETION
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_
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_
--- .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[
- for file in "${newconffiles
+ while [[ $# -gt 0 && "$1" ]]; do
+ newconffiles=( $(sed -n 's|^source[
+ for file in "${newconffiles
[[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
- sofar=" $(eval _muttconffiles \"$sofar\" $file) "
+ sofar=$
done
shift
done
@@ -80,8 +82,8 @@
conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
aliases=( $( sed -n 's|^alias[
- $(eval echo "${conffiles[@]}") ) )
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- "$cur" ) )
+ $(eval echo "${conffiles[
+ COMPREPLY=( "${COMPREPLY[@]-}" $( compgen -W "${aliases[*]-}" -- "$cur" ) )
return 0
}
@@ -101,7 +103,7 @@
sed -n '2,$s|^
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
ProcVersionSign
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)
PackageArchitec
ProcEnviron:
LC_CTYPE=
LC_COLLATE=C
PATH=(custom, user)
LANG=C
SHELL=/bin/bash
SourcePackage: bash-completion
tags: | added: patch |
Changed in bash-completion (Ubuntu): | |
status: | New → Confirmed |
summary: |
- bash_completion script errors: undefined variables, failed GLOB + errors with set -o nounset |
Another "undefined variable" error, but I'm not sure if the fix is correct:
--- .desktop- file-validate. ORIG 2010-09-08 06:14:56.000000000 -0400 file-validate 2010-10-11 16:18:22.215080283 -0400 {COMP_WORDS[ COMP_CWORD] } file_validate $filenames desktop- file-validate file_validate -o filenames desktop- file-validate
+++ desktop-
@@ -9,4 +9,4 @@
cur=$
_filedir '@(desktop)'
}
-[ "${have:-}" ] && complete -F _desktop_
+[ "${have:-}" ] && complete -F _desktop_