[Surfraw-devel] Re: Bug#269982: /etc/bash_completion.d/surfraw breaks bashes pwd command

Moritz Muehlenhoff jmm@inutil.org
Sun, 5 Sep 2004 10:43:12 +0200

Brian McDonald wrote:
> Package: surfraw
> Version: 2.0.2-1
> Severity: critical
> Tags: patch
> Justification: breaks unrelated software
> brian@4[brian]$ bash
> brian@4[brian]$ pwd
> /home/brian
> bash: pwd: write error: No such file or directory
> brian@4[brian]$

This is a bash bug that is fixed upstream. Unfortunately the fixed
version 3 didn't make it into sarge in time before the base freeze.

See 243872 for the complete history of the bug that I filed against

It's not really surfraw specific, but the surfraw bash completion
code seems one of the rare cornercases which trigger the bug.

> I take this to mean that stdout is being copied to stdout and then stdout is
> closed. I think closing stdout is the problem.
> I also think testing for a condition after the function has already been
> loaded into the enviroment may unnesessarily bloat the enviroment, so my
> modification to the file wraps the function in the test.
> Note my scripting abilities are poor but the following works for me:
> diff surfraw surfraw.new
> 1a2
> > if [ `type -p surfraw` ] ; then
> 26c27,28
> < type -p surfraw >&- && complete -F _surfraw surfraw sr
> ---
> > complete -F _surfraw surfraw sr
> > fi

This workaround seems valid. Unfortunately I won't have access to a sarge
system until tuesday.