Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 0/5] bashcompinit: several fixes
- X-seq: zsh-workers 30135
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 0/5] bashcompinit: several fixes
- Date: Sat, 28 Jan 2012 18:55:46 +0200
- Cc: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=1anRgt4XsTW7Zf98o6JFvZB2WXwGXOCXL+KytWaLvKQ=; b=VBv2Gpo6M2KSCKebuVUhUaewea542A2IXb22iotAa/t6Kf4Vi0HFYqTTRa9UpS+CG+ 6WasK8T4oV2uHysuv4+vDlFev4ZSgKZzvnEpPzIwCv+vn6NxuwbZHv1G5tEfrEqpvFZb ExDCOK6BOTCx/5Mg6lba8N/2d1oeZDRCA80VI=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hi,
While trying to resolve the issue I reported before[1], I stumbled upon many
problems in the current code, here are a bunch of patches that should address
all the issues I found.
I used the following test script to verify my changes, and now all the tests
pass, just like in bash :)
---
#!/bin/sh
if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit
fi
cwords[1]='first '
cwords[2]='second and space '
cwords[3]='third\\ quoted\\ space '
cwords[4]='fourth\\ quoted\\ space plus'
unescape()
{
printf "%b" "$1"
}
prepare()
{
local IFS=$'\n'
echo "== prepare =="
mkdir -p tmp
for e in "${cwords[@]}"
do
u=$(unescape "$e")
touch "tmp/$u"
done
}
compare()
{
test "$1" != "$2" && echo -e "error: '$1' != '$2'" && return -1 || return 0
}
_foo()
{
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${cwords[*]}" -- "$2") )
}
test_3()
{
local fail
echo "== test 3 =="
pushd "tmp"
for e in "${cwords[@]}"
do
compare "$(compgen -o filenames -f -- ${e:0:2})" "$(unescape "$e")" || fail=true
done
popd
test $fail || echo "OK"
}
test_2()
{
local fail
echo "== test 2 =="
for e in "${cwords[@]}"
do
compare "$(compgen -F _foo -- ${e:0:2})" "$(unescape "$e")" || fail=true
done
test $fail || echo "OK"
}
test_1()
{
local IFS=$'\n'
local fail
echo "== test 1 =="
for e in "${cwords[@]}"
do
compare "$(compgen -W "${cwords[*]}" -- ${e:0:2})" "$(unescape "$e")" || fail=true
done
test $fail || echo "OK"
}
prepare
test_1
test_2
test_3
---
[1] http://article.gmane.org/gmane.comp.shells.zsh.devel/24279
Felipe Contreras (5):
bashcompinit: remove _compgen_opt_words
bashcompinit: fix COMP_POINT
bashcompinit: fix quoting code
bashcompinit: simplify result matching code
bashcompinit: improve compgen -F argument passing
Completion/bashcompinit | 28 +++++++++++-----------------
1 files changed, 11 insertions(+), 17 deletions(-)
--
1.7.8.3
Messages sorted by:
Reverse Date,
Date,
Thread,
Author