From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17311 invoked by alias); 3 Dec 2013 22:49:49 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18190 Received: (qmail 13009 invoked from network); 3 Dec 2013 22:49:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-TMN: [Q48hc2Yb0K5kwAatbm1moy0avwtNlQp7] X-Originating-Email: [danielwallace@gtmanfred.com] Message-ID: Date: Tue, 3 Dec 2013 16:49:37 -0600 Subject: RE: Processing Arguments Importance: normal From: danielwallace To: TJ Luoma , Zsh-Users List Reply-To: danielwallace MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="--_com.android.email_428543088847110" X-OriginalArrivalTime: 03 Dec 2013 22:49:41.0160 (UTC) FILETIME=[F3C1DA80:01CEF079] ----_com.android.email_428543088847110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Try looking up zparseopts. It is along the same lines as bush's getopts. Daniel Sent via the Samsung GALAXY S=C2=AE4=2C an AT&T 4G LTE smartphone -------- Original message -------- From: TJ Luoma Date: 12/03/2013 4:47 PM (GMT-06:00) To: Zsh-Users List Subject: Processing Arguments I'm sure there has to be a better way of doing this=2C but the way that I'v= e done it has always worked for me=2C so I've never bothered to look furthe= r. Here's what I do: ANOTHER=3Dno SOMETHING=3Dno for ARGS in "$@" do case "$ARGS" in -s|--something) SOMETHING=3Dyes shift =3B=3B -a|--another) ANOTHER=3Dyes shift =3B=3B -*|--*) echo " $NAME [warning]: Don't know what to do with arg= : $1" shift =3B=3B 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. ----_com.android.email_428543088847110--