From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27585 invoked by alias); 1 Dec 2017 07:12:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42063 Received: (qmail 29221 invoked by uid 1010); 1 Dec 2017 07:12:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-it0-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.214.44):SA:0(-1.9/5.0):. Processed in 9.856833 secs); 01 Dec 2017 07:12:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=Ce3TwUZZQuaglH2ZEw1dc5QAbZUaucl8swRLYXIF1E4=; b=y///DGNQlHMMUNGxwPkcGetSaPyoFMnYPyjrSedhkp24K7ulvFcRT9Ay8qcRwn+wkx qCvLgQO8S3nyk3fbAqPQtRhXBdOgDb41WMSEQWANV3Jml9kJuGJslOkeL67YPbpYcWfg rKS3Mx5il7Asa0mEdaamC1KJVXfxqxYKQTrhzk74GBbCYyVboLSFqqupe8S01v4p3fiP XXoOmiEVv6HMdg3aMvjsbtJi4hLNKe9mzR0hMZd/n1sWczzncA2b0LJJh92F7eiPR0FW ym1X5lnXyNl7wGRnaeMSZDm69JkWrMneCgoy2rXrH6NmpPlZMgOkgfkqvbgtSsziEzX/ 6QAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=Ce3TwUZZQuaglH2ZEw1dc5QAbZUaucl8swRLYXIF1E4=; b=HTwaC1ra8zFjAt4Uw56xo/eO4IR7sU1y+/t8fsVdm+rTmoYnZvoC5ZXsrlgult0i2b kjFt/tLwbIxJaMS7rlQU6PhmmKzKb1yjUjXsT4NWI1IZPPyChlgHONYSbP2tipqsCP6J sn+/tXhQu313BykVrXS2AsD8hlOoXhB121+MNNJb9pMw+9YH18RbLoVbj0mYUMqcYY8n tbcnLNqV7n1Yhy30M6TxNVs4rD52N2WNZzgG71WgLcTGTNsRRYFYmOzTNZfOqf3eiv77 3M43UYw6+rJvR07FAR+d1KoFCrguMr90fkwOZSOFf6TeWJKtGM3Apuz7oosMtgxHZ+gJ 5FlQ== X-Gm-Message-State: AKGB3mIpNH+lxaBUFW+RcuG5zoUzynzpP6MRlM0ErBiZVgbTkpcV0tdJ SJHCth2uOh/UC4HUniYC6FRZyDQ9mHY= X-Google-Smtp-Source: AGs4zMYyxqrr4TmQRv8Q2N1ThzYmftLajtnnuhmwENAQ3YgR2BfnSQT226LuyBaErV2oFYn3mLopJg== X-Received: by 10.36.80.148 with SMTP id m142mr726326itb.6.1512112336888; Thu, 30 Nov 2017 23:12:16 -0800 (PST) From: dana Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] getopts: Accurately report '-x' or '+x' in error messages Message-Id: <733779CE-86B9-4178-B38B-7E64390BB4C6@dana.is> Date: Fri, 1 Dec 2017 01:12:15 -0600 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3273) Related to zsh-workers 40010: getopts error messages about illegal options or missing values always = reference the -x variant of the option, even if the +x one was used instead. The = included patch simply makes it report the correct prefix. PS: There are a few other places in the code where it seems that the - = prefix is hard-coded into the error message, but i didn't actually check to see if = that was a problem. This patch in addition to the previous one should cover = most cases people are likely to run into, though, i'd think. PPS: I didn't add any tests because there aren't any for getopts =E2=80=94= let me know if you'd like me to create some. dana diff --git a/Src/builtin.c b/Src/builtin.c index 0ff9e4f16..f002b9912 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5442,8 +5442,9 @@ bin_getopts(UNUSED(char *name), char **argv, = UNUSED(Options ops), UNUSED(int fun if(quiet) { zoptarg =3D metafy(optbuf, lenoptbuf, META_DUP); } else { - zwarn(*p =3D=3D '?' ? "bad option: -%c" : - "argument expected after -%c option", opch); + zwarn(*p =3D=3D '?' ? "bad option: %c%c" : + "argument expected after %c%c option", + "?-+"[lenoptbuf], opch); zoptarg=3Dztrdup(""); } return 0;