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

Re: Completion function for bitkeeper?



[This should move to zsh-workers?]

On Nov 14,  4:23pm, Peter Stephenson wrote:
} Subject: Re: Completion function for bitkeeper?
}
} Bart Schaefer wrote:
} > Word splitting is vastly different in the two cases.  It happens within
} > the words of $action in the second case, but does not in the first case.

That's a bit incoherent, let me try again.

Consider what happens when there are command separators in the values of
$action.  Suppose e.g. that

	action=( \{ foo '&&' bar \} )

}                 while _next_label "$subc" expl "$descr"; do
}                   eval "$action[2,-2]" && ret=0
}                 done

In the above case we execute the equivalent of

	foo && bar && ret=0

However, if instead

	action=( ' ' foo '&&' bar )

} 	        eval "action=( $action )"
}                 while _next_label "$subc" expl "$descr"; do
}                   "$action[@]" && ret=0
}                 done

In this second case it's a syntax error.  I suppose it could be argued
that the second case is unnecessary because it's only a shorthand for
the first case with only one command in the braces.

Also in the second case the eval has been factored out of the loop
because we're always interested in the entire value of "$action" and
it's fractionally more efficient to do the "eval" once only.

However, on third thought, it could be argued that the second case has
a bug.  Consider

	action=( " foo ) && bar=( oops" )



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