From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1350 invoked from network); 25 May 2022 09:49:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 May 2022 09:49:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653472162; b=bqKvPxBvPuKoBaURvOVoJCzZmqz/w/2PkLpwlTLq0N5S7pVHyJRcaCgn0qmxlbJb7jYiwoAp3i iJLJoGZAYqp2T38oFYhBdd6m0VrmVha/KhAvEplMYM5DtZaOCSaEGJTh9H2+YaRqFpLZR++aWb RowFxW7USsr6/0YyZ5CRtk1EViHVR1qqFC3WIpSULquKs4ow0vwYnXbLs6rr++mWVorrqJIoGC V9jm1hzh1Qwqzx57M2yed22FY2Fc5m/wsFlKnsCMWb594W356HK6WzLo5rmryuQPYtP02qYabS cecPagawb+4rvGjwiFhBS1E5htFojlXf21b+w4VhtEQxpQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653472162; bh=5OI/K95D2nQklfVo9GisLqbrjN7xo3Hu8B0lRpTjXGU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=Ee71SxIaLjJ5tHHKzHJGqaian2jLYjbnRJLfh3t2Lj+wMlR5F+gK7vJ+ikHL9QQ4T0oIdjJW9W Z4ZDauhtQDlvkRpRay/qOZNpIla+A0CWpKfOJzzA0yV+7Z1xNemfyrMt4mm6xKKaSCT2zZrdqg 5a2ogwWpmSQcCnxJaLQogZNVs8fpHYjEQ7Cg+nk5xLdGaeVBlKSherUVbftnkudXtusrrpf7af j9pDC0Y8NEyL+7gYcUVLDzEwjsr8tuFkNG2BBl9vaZYExN2qq8cvIQNI5kpgOtH2Kpu4Ha5GbI TlwU8yJQnvt4qaHyLoXm761j4n8us4kJ8uCPl7dPKY0uAQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=s8vu1AjpAO5j1jn5jUaoP7Yl9bhcZFgp6egYQHItXsE=; b=R9fQoqjUtK+rdJEaNBYKm/WRZn UYeIVIpssjPoz4AZ/voxg/ozo6lbIVB6CuGi20Stq5/GmoYhAesFHIe9BKqYRqKPrFnN5TVwOol9g AeFYKCuzVhPGiSptiEwqrcDzY2i9Wz61kuCKSMkvu15Jn4MxzcCv8r2vlHQtW66QqpgMQDl+kdETO 4DgBBpreLNO3bwLH9ISp/Rmo8BEEpDdb6BIQ58pnCAysP4PFtdJEnAIlyRGWDXfO9X1ix1gOaDVMZ Yw249i7mDpkcZ///Yw8ADL7xCEJp1URORtP73WPCkTWnLeoRPgMrcCtP66Rsc9k2v6g+67hFi0Af1 9jsE1ToQ==; Received: from authenticated user by zero.zsh.org with local id 1ntndp-0002z9-Eb; Wed, 25 May 2022 09:49:21 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:49202) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1ntndG-0002ew-RX; Wed, 25 May 2022 09:48:48 +0000 Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1ntndG-0002jz-G3 for zsh-workers@zsh.org; Wed, 25 May 2022 11:48:46 +0200 Received: from oxbe13.tb.ukmail.iss.as9143.net ([172.25.160.144]) by smtp1.tb.ukmail.iss.as9143.net with ESMTP id tndGn52bsVu5XtndGnhP60; Wed, 25 May 2022 11:48:46 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 172.25.160.144 X-CNFS-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=628dfb7e cx=a_exe a=wuFMYA7voKp1dZz7Z+vj5Q==:117 a=wbvTLvLwOfMA:10 a=IkcTkHD0fZMA:10 a=7H6ixmLU1AQA:10 a=NLZqzBF-AAAA:8 a=pGLkceISAAAA:8 a=wz1Jalq1BIxsdbptsJoA:9 a=QEXdDO2ut3YA:10 a=wW_WBVUImv98JQXhvVPZ:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1653472126; bh=5OI/K95D2nQklfVo9GisLqbrjN7xo3Hu8B0lRpTjXGU=; h=Date:From:To:In-Reply-To:References:Subject; b=btCZbLeh4s9w6qivqunUilsJndybu7v1txlvXsq3xAeeAS2TfNNtTxd0xbFtMun6O KiQ19hXzdHXV5Eqk0C3hrz1ofdVG/S5kiPcpqnMgagyHLwSULZLHkMmHryGKBl/x2/ 81DB7NMk1WDhvdJk0oTyduIDjBNOMaQczZKMJX6OjXQTTc/iFXytmNp7mwXNkOAGrb h4eeMCe7Vhzvafh4wYYjDhUxtRmPbdvkhU9w18Uk5p9++mSOHricQFN3MMSlHE1xs9 tzjr31bZA+QH3pWtZyX4LBNtdcXQtP4DQhByPfdMB1/FE82WguwlKMidlGlTFUU2iZ bYeDjGElJBZNw== Date: Wed, 25 May 2022 10:48:46 +0100 (BST) From: Peter Stephenson To: Risto Laitinen , zsh-workers@zsh.org Message-ID: <440344651.366684.1653472126201@mail2.virginmedia.com> In-Reply-To: <641523655.251203.1653056242563@mail2.virginmedia.com> References: <641523655.251203.1653056242563@mail2.virginmedia.com> Subject: Re: [PATCH] zed fails with setopt nounset unless option -x is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 147.161.167.85 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfPa1VN9pKn16YJ++yY8iCvd93I7hRYqT/17dRybCcNf3j/wM24Nb6mK1J//5D7t2as1ZURYMqAA56DJ4Qf5sdBGaytFGRnubHfbZPDntYeg4e23jRJJm I7KWVA3wj2ER98Qf1k7N8d8qgxGyyHGkYp4pZYHWw0JhxTOIxtmFP3d6F37Mrp93Zl/n25L/00jUMthjdCz58o+zT792Tky6RDCkQiMb7qVK04yIbaiwNCHB gjt0li3EIsYO9bqOimHdyPZEKkTf7/DID18wdd+ZjY0= X-Seq: 50286 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > On 20 May 2022 at 15:17 Peter Stephenson wrote: > > > > On 20 May 2022 at 15:06 Risto Laitinen wrote: > > % zsh-5.9 -f > > % autoload zed > > % setopt nounset > > % zed a.txt > > zed:21: opts[-x]: parameter not set > > % > > Looks straightforward. This is a little better (it doesn't take account of the point Bart noted). The option handler will return on a bad argument, so actually the internal handling is now redundant. pws diff --git a/Functions/Misc/zed b/Functions/Misc/zed index 7d0d590db..bb075512c 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -14,15 +14,17 @@ local var opts zed_file_name integer TMOUT=0 okargs=1 fun hist bind local -a expand -zparseopts -D -A opts f h b x: +zparseopts -D -A opts f h b x: || return 1 fun=$+opts[-f] hist=$+opts[-h] bind=$+opts[-b] -if [[ $opts[-x] == <-> ]]; then - expand=(-x $opts[-x]) -elif (( $+opts[-x] )); then - print -r "Integer expected after -x: $opts[-x]" >&2 - return 1 +if (( $+opts[-x] )); then + if [[ $opts[-x] == <-> ]]; then + expand=(-x $opts[-x]) + else + print -r "Integer expected after -x: $opts[-x]" >&2 + return 1 + fi fi [[ $0 = fned ]] && fun=1