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

A useful alias for zsh scripting

Suppose you have a function that takes several positional parameters.  It's
often difficult to keep track of what each of them means.  If you use $1 $2
etc. throughout your function, it becomes a chore to add parameters or to
change the order, so you probably end up doing something like:


and then using those names elsewhere in the function.

Here's a handy alias to make it much easier to assign names to positional
parameters.  You use it like this:

	nameparams thingtodo nameofthing whattosay

and the effect is the same as the three assignments above.  The one thing
this can't handle is positional parameters containing \0 (nul) bytes.

	alias nameparams 'print -rnN $* | IFS=$(print -N) read'

If somebody knows a better way than $(print -N) to get a nul into IFS, I'm
all ears.

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

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