zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 0/5] bashcompinit: several fixes
@ 2012-01-28 16:55 Felipe Contreras
  2012-01-28 16:55 ` [PATCH 1/5] bashcompinit: remove _compgen_opt_words Felipe Contreras
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Felipe Contreras @ 2012-01-28 16:55 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-29 18:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-28 16:55 [PATCH 0/5] bashcompinit: several fixes Felipe Contreras
2012-01-28 16:55 ` [PATCH 1/5] bashcompinit: remove _compgen_opt_words Felipe Contreras
2012-01-28 16:55 ` [PATCH 2/5] bashcompinit: fix COMP_POINT Felipe Contreras
2012-01-28 16:55 ` [PATCH 3/5] bashcompinit: fix quoting code Felipe Contreras
2012-01-28 16:55 ` [PATCH 4/5] bashcompinit: simplify result matching code Felipe Contreras
2012-01-28 16:55 ` [PATCH 5/5] bashcompinit: improve compgen -F argument passing Felipe Contreras
2012-01-28 17:14   ` Felipe Contreras
2012-01-29 18:25 ` [PATCH 0/5] bashcompinit: several fixes Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).