Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: experimental new style completion



On Jan 22,  4:18pm, Phil Pennock wrote:
} Subject: Re: experimental new style completion
}
} Whilst it's nice and understandable to people who're extensively
} familiar, doesn't anyone else think it's time to sit back and try and
} look at this syntax objectively?

It surely is gory, but there's only so much that can be done to clarify
it, particularly with the constraint that it can't conflict with any
syntax used by either the Bourne or Korn shells.  However, it's not as
bad as you imply; there are stylistic issues.

	eval b\=\( \$\{b:/\*\(${(j:|:)fignore}\)\} \)

I wouldn't have used all those backslashes ... I prefer quotes:

	eval 'b=( ${b:/*('${(j:|:)fignore}')} )'

which leaves just two oddities:  The (|) glob alternation syntax and the
admittedly icky parameter flags syntax.  It becomes slightly more readable
if you replace the `:' with matching parens or braces:

	eval 'b=( ${b:/*('${(j(|))fignore}')} )'

Would it help to have written it this way?

	fignore_alternatives="${(j(|))fignore}"
	fignore_glob="*($fignore_alternatives)"
	eval 'b=( ${b:/'$fignore_glob'} )'

The final nasty bit here is the need to "eval" to strip the quoting from
the `|' characters in the alternatives, so that the glob will work right.

For those still confused, the whole mess is the same as:

	b_=()
	for i in "$b[@]"
	do
	    for j in "$fignore[@]"
	    do
	    	case "$i" in
		*${j}) continue 2 ;;
		esac
	    done
	    b_=("$b_[@]" "$i") 
	done
	b=("$b_[@]")

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author