From: TJ Luoma <luomat@gmail.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: Processing Arguments
Date: Tue, 3 Dec 2013 17:44:18 -0500 [thread overview]
Message-ID: <r422Ps-1090i-AF5B036F96E94F7FBAAB77F009320ECB@Air.local> (raw)
I'm sure there has to be a better way of doing this, but the way that I've done it has always worked for me, so I've never bothered to look further.
Here's what I do:
ANOTHER=no
SOMETHING=no
for ARGS in "$@"
do
case "$ARGS" in
-s|--something)
SOMETHING=yes
shift
;;
-a|--another)
ANOTHER=yes
shift
;;
-*|--*)
echo " $NAME [warning]: Don't know what to do with arg: $1"
shift
;;
esac
done # for args
The only downside to this is that you can't combine arguments such as `-sa` you have to use `-s -a`
Am I right? Is there a better way?
TjL
ps - I'm not _overly_ concerned with "portability" to other shells. I write zsh scripts because I like what zsh has to offer.
next reply other threads:[~2013-12-03 22:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 22:44 TJ Luoma [this message]
2013-12-03 22:49 danielwallace
2013-12-04 7:27 ` Bart Schaefer
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=r422Ps-1090i-AF5B036F96E94F7FBAAB77F009320ECB@Air.local \
--to=luomat@gmail.com \
--cc=zsh-users@zsh.org \
/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).