zsh-users
 help / color / mirror / code / Atom feed
* A useful alias for zsh scripting
@ 1998-06-12 16:52 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 1998-06-12 16:52 UTC (permalink / raw)
  To: zsh-users

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:

thingtodo=$1
nameofthing=$2
whattosay=$3

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-06-12 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-12 16:52 A useful alias for zsh scripting Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).