Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Processing Arguments
- X-seq: zsh-users 18189
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Processing Arguments
- Date: Tue, 3 Dec 2013 17:44:18 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:message-id:mime-version:content-type :content-transfer-encoding; bh=8bq6bSZkh3rDel2pYCqCDr/3G+6Dfe9a4kUXjvGuAV4=; b=tdt7NfVaTPniR393mYzxJlk0r4gc0jDpagwMBtuOX5c7EN+2075FE5keSZq4Gnn9GT Qv3EAgti7aajZ0dFdEhJR6U78hrxI9tfevY0EJkopVgsFF1AbOq6b6KmRYkAfNpjDDJ9 5QGNnNPZD7W1jUDG7D4muZqDvYbPo7CS88Cr7JxJmCWkSmkRcwCjPTvYqkPNp2DfihYt stHslk+dcPDivowdfccqGOX5QG5CPOKpU1zTxF67zEndXZXW8HwM5buCcpclaio+EZuZ kYhwbSV4y5M2wOD7D1ZkWM+5mk9Mrf18pwmI7kHKatFchj2RJA+qMjRTNUFj20drAfaH 3IcA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author