zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@math.gatech.edu
Subject: A useful alias for zsh scripting
Date: Fri, 12 Jun 1998 09:52:08 -0700	[thread overview]
Message-ID: <980612095209.ZM22186@candle.brasslantern.com> (raw)

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


                 reply	other threads:[~1998-06-12 16:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980612095209.ZM22186@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).