From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14631 invoked from network); 31 Aug 2005 15:41:25 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Aug 2005 15:41:25 -0000 Received: (qmail 32233 invoked from network); 31 Aug 2005 15:41:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Aug 2005 15:41:18 -0000 Received: (qmail 29191 invoked by alias); 31 Aug 2005 15:41:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9361 Received: (qmail 29181 invoked from network); 31 Aug 2005 15:41:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 31 Aug 2005 15:41:10 -0000 Received: (qmail 31203 invoked from network); 31 Aug 2005 15:41:10 -0000 Received: from ns9.hostinglmi.net (213.194.149.146) by a.mx.sunsite.dk with SMTP; 31 Aug 2005 15:41:02 -0000 Received: from 212.red-80-35-44.pooles.rima-tde.net ([80.35.44.212]:32769 helo=localhost) by ns9.hostinglmi.net with esmtpa (Exim 4.52) id 1EAUhz-0003dL-S2 for zsh-users@sunsite.dk; Wed, 31 Aug 2005 17:41:04 +0200 Date: Wed, 31 Aug 2005 17:44:54 +0200 From: DervishD To: Zsh Users Subject: How to handle unknown options in zparseopts Message-ID: <20050831154454.GA122@DervishD> Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.2.1i Organization: DervishD X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns9.hostinglmi.net X-AntiAbuse: Original Domain - sunsite.dk X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - dervishd.net X-Source: X-Source-Args: X-Source-Dir: X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 Hi all :) After the suggestion of Doug for using zparseopts, I'm facing a different problem. I don't want my script silently ignore unknown options, I want to consider that an error. I don't know how to do it since zparseopts doesn't report errors, so I've written this: #!/bin/zsh emulate -L zsh typeset -A OPTIONS zparseopts -D -A OPTIONS -- -help+ tmp=$argv[1] [[ "$tmp[1]" == "-" ]] && { print "ERROR, unknown option \"$tmp\"" return 1 } # Handle here the other (valid) options return 0 That's pretty ugly and not very clean, neither :( But, worse, zparseopts spits an error in this case: set -- -a zparseopts -a array -- a: OK, it returns '1' but I'm pretty sure that it returns that value for other errors, so I cannot 'silent' zparseopts by redirecting to /dev/null and doing my own handling. Am I missing anything obvious? If I must handle myself unknown options and the missing argument problem, I think I better use getopts and handle long options myself :? GNU getopt is just another pain in the arse, so... Thanks in advance :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net http://www.pleyades.net & http://www.gotesdelluna.net It's my PC and I'll cry if I want to...