[Bash-completion-devel] Bug#502804: {Spam?} syntax errors when sourcing bash-completion with POSIX enabled

Freddy Vulto fvulto at gmail.com
Sun Oct 19 21:29:33 UTC 2008


Package: bash-completion
Version: Latest version from http://bzr.debian.org/bzr/bash-completion/current
Severity: normal

Steps to reproduce the problem:

   $ set -o posix
   $ source bash_completion

Expected output:
No errors

What do you see instead?
Instead I receive three errors (after solving the first, the next becomes apparent):

bash: /mnt/proj/bashCompletion/bash_completion-debian.bzr/bash_completion: line 275: syntax error near unexpected token `<'
bash: /mnt/proj/bashCompletion/bash_completion-debian.bzr/bash_completion: line 275: `	done < <( compgen -d -- "$(quote_readline "$cur")" )'


bash: /mnt/proj/bashCompletion/bash_completion-debian.bzr/bash_completion: line 9585: syntax error near unexpected token `<'
bash: /mnt/proj/bashCompletion/bash_completion-debian.bzr/bash_completion: line 9585: `	done < <( compgen -d -- "$(quote_readline "$cur")" )'


bash: `_ssh-copy-id': not a valid identifier


The solution is to rewrite the redirected while loops (bug 1 & 2) and to remove the hyphens from _ssh-copy-id (bug 3).  See diff underneath.  See also:
- http://fvue.nl/wiki/Bash:_Append_to_array_using_while-loop
- http://www.fvue.nl/wiki/Bash:_Piped_`while-read'_loop_starts_subshell


=== modified file 'bash_completion'
--- bash_completion	2008-10-10 19:01:59 +0000
+++ bash_completion	2008-10-19 21:07:12 +0000
@@ -270,15 +270,23 @@
 	_expand || return 0
 
 	local toks=( ) tmp
-	while read -r tmp; do
-		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
-	done < <( compgen -d -- "$(quote_readline "$cur")" )
+	toks=( ${toks[@]} $(
+		compgen -d -- "$(quote_readline "$cur")" | { 
+			while read -r tmp; do
+				[[ -n $tmp ]] && echo $tmp
+			done
+		}
+	))
 	
 	if [[ "$1" != -d ]]; then
 		xspec=${1:+"!*.$1"}
-		while read -r tmp; do
-			[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
-		done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
+		toks=( ${toks[@]} $(
+			compgen -f -X "$xspec" -- "$(quote_readline "$cur")" | {
+				while read -r tmp; do
+					[[ -n $tmp ]] && echo $tmp
+				done
+			}
+		))
 	fi
 
 	COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
@@ -9572,13 +9580,21 @@
 
 	local toks=( ) tmp
 	
-	while read -r tmp; do
-		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
-	done < <( compgen -d -- "$(quote_readline "$cur")" )
+	toks=( $(
+		compgen -d -- "$(quote_readline "$cur")" | {
+			while read -r tmp; do
+				[[ -n $tmp ]] && echo $tmp
+			done
+		}
+	))
 
-	while read -r tmp; do
-		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
-	done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )	
+	toks=( $(
+		eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" | {
+			while read -r tmp; do
+				[[ -n $tmp ]] && echo $tmp
+			done
+		}
+	))
 	
 	COMPREPLY=( "${toks[@]}" )
 }

=== modified file 'contrib/ssh'
--- contrib/ssh	2008-09-27 10:58:42 +0000
+++ contrib/ssh	2008-10-19 21:12:07 +0000
@@ -74,9 +74,9 @@
 }
 complete -F _scp $nospace scp
 
-# ssh-copy-id(1) completion
+# ssh_copy_id(1) completion
 #
-_ssh-copy-id() {
+_ssh_copy_id() {
 	local cur prev
 
 	COMPREPLY=()
@@ -96,5 +96,5 @@
 
 	return 0
 }
-complete -F _ssh-copy-id $filenames ssh-copy-id
-}
\ No newline at end of file
+complete -F _ssh_copy_id $filenames ssh-copy-id
+}




-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-6-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)






More information about the Bash-completion-devel mailing list