[Bash-completion-devel] Bug#551780: Bug#551780: Fix by reading from avahi-browse with a timeout

Crestez Dan Leonard cdleonard at gmail.com
Wed Mar 24 03:07:18 UTC 2010


On Mon, 2010-03-22 at 19:07 +0000, Freddy Vulto wrote:
> Crestez Dan Leonard <cdleonard <at> gmail.com> writes:
> > I had to mangle +o posix to get tests to pass. I don't know why the test
> > suite puts the shell into posix mode anyway.
> 
> Because users 'out there' might run bash-completion in bash POSIX mode.  I
> regard POSIX as just stricter bash script and supportable with little effort, so
> I put it in the test suite to make sure bash-completion honours POSIX.  A
> notable error is that POSIX doesn't allow a hyphen (-) in a function name,
> whereas standard bash does allow:
> 
>     $ f-a() { echo foo; }
>     $ set -o posix
>     $ f-a() { echo foo; }
>     bash: `f-a': not a valid identifier
> 
> Perhaps the test suite should test completions both with and without POSIX
> mode...
> 
> Another solution - if bash-completion really demands noPOSIX :-( - could be to
> disable POSIX on entering bash-completion and restore POSIX (if it was enabled)
> on exit, but this 'on exit' is hard to catch...
shopt -s extglob is already done globally and not reverted, doing set +o
posix the same way would not be much worse.

I don't think it's possible to change modes on the fly correctly. If you
do some long operation between set +o posix and set -o posix and ^C
between them then the change will leak to the shell. The only way around
this would be to use a subshell; but you can't write to COMPREPLY from a
subshell. I assume trapping is unacceptable for bash-completion.

But I found a different way around process substitution. It's possible
to pipe a () to a {} and kill the () when you're through with it. I
attached this second variant.

The only problem I found now is that it depends on bash-4 for at least
$BASHPID and read -t with fractional arguments. The fractional timeout
issue makes me think a compatible fix is not worth doing. Bash-3.2 can
still use the blocking implementation. What do you think?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avahi-fix2.diff
Type: text/x-patch
Size: 3209 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20100324/674d4a58/attachment-0003.bin>


More information about the Bash-completion-devel mailing list