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

PATCH: _arguments (Re: PATCH: use _arguments in _which and _unhash)



On May 28,  6:35pm, Oliver Kiddle wrote:
} Subject: PATCH: use _arguments in _which and _unhash
}
} Bart Schaefer wrote:
} 
} > } % zpty -w l <tab>
} > } _arguments:shift:297: shift count must be <= $#
} > 
} > I can't reproduce that.
} 
} Are you sure? I can reproduce it on different platforms and when
} starting with zsh -f. Maybe one of your options avoids it.

Yup, you're right, I can reproduce it with -f.

Is there a more efficient fix than the following?  (This relies on the
first argument of shift being interpreted as a math expression.)

Index: Completion/Base/_arguments
===================================================================
@@ -285,7 +285,7 @@
 
               # Otherwise we call it with the description-arguments.
 
-              eval "action=( $action )"
+              set -A action ${=~action}
               while _next_label "$subc" expl "$descr"; do
                 "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}"
 	      done
@@ -293,9 +293,9 @@
             fi
           fi
         fi
-        shift 1 descrs
-        shift 1 actions
-        shift 1 subcs
+        shift "${#descrs} ? 1 : 0" descrs
+        shift "${#actions} ? 1 : 0" actions
+        shift "${#subcs} ? 1 : 0" subcs
       done
 
       if [[ -z "$matched$hasopts" ]] && _requested options &&

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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