Hello, I am trying to improve the bash_completions for mercurial. For a specific command (hg add), I want to show only files eligible for addition as completions. The command "hg status -nu" lists such files, so what I do is this:
<snip> local files="$("$hg" status -n$1 . 2>/dev/null)" local IFS=$'\n' COMPREPLY=([EMAIL PROTECTED]:-} $(compgen -W '$files' -- "$cur")) <snap> However, there are problems with filenames containing spaces. with the above code, spaces are not escaped on the command line, i.e. a $ hg add TE<tab> leads to $ hg add TEST FILE I tried escaping the spaces in the first line above like this: local files="$("$hg" status -n$1 . 2>/dev/null | sed 's/ /\\ /g')" With this code in place, the results on the command line are OK, but not the completion list that appears when hitting <tab> on an ambiguous prefix: $ hg add T<tab><tab> T1 TEST\ FILE Notice the backslash that should not appear (at least it is not there for completion for ls). I have already tried the "-o filenames" option to compgen, with no success. Is what I want at all possible with the current bash (I used GNU bash, version 3.2.25(1)-release (i486-pc-linux-gnu) from KUbuntu 7.10)? If not, can you fix it (e.g. by improving the "-o filenames" option)? Best regards and thanks in advance, Jonas