2012/4/12 SZEDER Gábor <szeder@xxxxxxxxxx>: >> +{ >> + local name="${2-$1}" >> + local cmd="${name#git_}" >> + eval "$(typeset -f foo_wrap | sed -e "s/foo_cmd/$cmd/" -e "s/foo/_$name/")" >> + complete -o bashdefault -o default -o nospace -F _${name}_wrap $1 2>/dev/null \ >> + || complete -o default -o nospace -F _${name}_wrap $1 >> +} >> + >> +git_complete git >> +git_complete gitk > > Clever ;) > > But it needs a subshell and a sed invocation, so Windows people might > not be all too happy about this. Perhaps it's not a big deal in the > default case, because it will be done only twice at startup time. > However, if someone wants several aliases on Windows, it can cause > noticeable delay. It's a startup speed vs. convenience trade-off. > Anyway, I don't have any ideas how those fork()s and exec() could be > avoided. Well, if you look at the foo_wrap function you would notice there is not much 'foo' in it. We could have a __git_wrap () function instead, but we would need to find an alternative way to set the 'cmd' variable. The easiest would be to just don't set it at all. As I suggested, only __git_complete_remote_or_refspec needs it, and can be easily worked around. -- Felipe Contreras -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html