8287cc177e993aebc8ee0a9f5ee5a1cee6893253
- Author
- Nick Stenning <nick@whiteink.com>
- Committer
- Nick Stenning <nick@whiteink.com>
- Date
Message
Better cake completion: don't barf on options, and don't clobber user's namespace
Diff
1diff --git a/plugins/cake/cake.plugin.zsh b/plugins/cake/cake.plugin.zsh
2index f968c71d582a35a9e175f0fc3a55d220f71d85fe..1d0d196ee194a15027e405b9f737fc96bbc67fea 100644
3--- a/plugins/cake/cake.plugin.zsh
4+++ b/plugins/cake/cake.plugin.zsh
5@@ -1,18 +1,22 @@
6 # Set this to 1 if you want to cache the tasks
7-cache_task_list=1
8+_cake_cache_task_list=1
9
10 # Cache filename
11-cache_file='.cake_task_cache'
12+_cake_task_cache_file='.cake_task_cache'
13+
14+_cake_get_target_list () {
15+ cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
16+}
17
18 _cake_does_target_list_need_generating () {
19
20- if [ $cache_task_list -eq 0 ]; then
21+ if [ ${_cake_cache_task_list} -eq 0 ]; then
22 return 1;
23 fi
24
25- if [ ! -f $cache_file ]; then return 0;
26+ if [ ! -f ${_cake_task_cache_file} ]; then return 0;
27 else
28- accurate=$(stat -f%m $cache_file)
29+ accurate=$(stat -f%m $_cake_task_cache_file)
30 changed=$(stat -f%m Cakefile)
31 return $(expr $accurate '>=' $changed)
32 fi
33@@ -21,12 +25,12 @@ _cake_does_target_list_need_generating () {
34 _cake () {
35 if [ -f Cakefile ]; then
36 if _cake_does_target_list_need_generating; then
37- cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$' > $cache_file
38- compadd `cat $cache_file`
39+ _cake_get_target_list > ${_cake_task_cache_file}
40+ compadd `cat ${_cake_task_cache_file}`
41 else
42- compadd `cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'`
43+ compadd `_cake_get_target_list`
44 fi
45 fi
46 }
47
48-compdef _cake cake
49+compdef _cake cake