From patchwork Tue Jun 2 20:55:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felix Dietrich X-Patchwork-Id: 6531491 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5003C0020 for ; Tue, 2 Jun 2015 20:55:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18BE72042B for ; Tue, 2 Jun 2015 20:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8157820412 for ; Tue, 2 Jun 2015 20:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751144AbbFBUzO (ORCPT ); Tue, 2 Jun 2015 16:55:14 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60893 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbbFBUzO convert rfc822-to-8bit (ORCPT ); Tue, 2 Jun 2015 16:55:14 -0400 Received: from localhost ([85.181.63.192]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0M4NmW-1ZIm2s3HuW-00ykH9 for ; Tue, 02 Jun 2015 22:55:10 +0200 From: Felix Dietrich To: dash@vger.kernel.org Subject: [MAN] Fix description of getopts when last argument reached Date: Tue, 02 Jun 2015 22:55:19 +0200 Message-ID: <87r3pt6dag.fsf@sperrhaken.name> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 X-Provags-ID: V03:K0:sjKIHNvcYqpevrwHcniEALNFW7RKUrW7oYrqonHSnDYH7LCx38f L7+dzlDGHHLN/H6v8HSM9q3bjQ2e55K9oDq13IJfBMQbfyTRyvT5X8uD95NmO5rDwfYA0Qv 2zjPqP9luCbiiaXykhSZzcsIiveuXZ5L2McLFV/PYCEiUWulkyhzHet87I+YJScobrr2BSM QgzAWuEGSWwPyf6Z5fNdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:l20MT9dg8z0=:VqzZuQPkbzDI/cvJjqIABr 4O2iAhItPBQ6HhzDssronLCMHGmKVwkVxuJVv3SS94Vd4RgRs+TGg8EvpUTdJ0wlKxG7teWEA 5vfKqd4zkpqUXBZ6OsvDtSkc9OlkwxnV372mrhOgDaJ+d9qCvwtOGDQZiE+iSYDDjSBDjLqdj fA4OaapZtcwtjFSrM5PreS7rD0qi1whqevoLrQ7vLgH7s+NsG/d2tmpZGRrNEjRe2Qbv9VV/r 6osWfB4fhSEGq708Pz5SmL/SIerjm3G5/C0HtmyL5/2MR4MFO9gx1ju690z0PCQy1YTStiM+a OnlpsY4Pew0HieNzv7gbG7q7We3CdiZC6SFhfu8h9clsyVJxyoJyGvjpesfuVSvwGBIMZmKAV sC5zScgcAe88VUsrReZ2u1ADHQWdqA7WhGj3F4OG7UkAA3JCP0650q8cUYxDB7rCylSfHdyTw M/wzqwivCE8B94rxoTFE3Rgvc4CXmSi32FtbJafpON9Fs/8jt0eaLEKyp25SEFdwqkobxoeEr nWp4wh/xLLVXeRKpemRp5IYfQ8nVezUGO/prOmO0Uce0cL/GxEiz9YzQcjelMBxJCmNXe/DxV ulsOtvp2L93EkDeLP67s1lfir8fSrLCezyetenACfzHRN4hnuW4Yk/rXTxPELxFK2QtFkl/d5 JsF8C3ewJTVurRMQnFqce6S8aCvIlEpSigwQWeIBRdFYkOw== Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- When I read the getopts description in the man-page I got stumped by the following part: getopts optstring var [..] If there are no remaining arguments, getopts will set var to special option, “--”, otherwise, it will set var to “?” [..] After I was unable to get getopts to store "--" in var, I asked for help on comp.unix.shell [1] where it was pointed out to me that actually the POSIX description of getopts [2] does not include a special option "--"; dash's behaviour of setting var to "?" after the last argument is correct and that this is most likely an error in the documention. In case this is not an error: Under what circumstances will var be set to "--"? Could you provide an example? [1] https://groups.google.com/forum/#!topic/comp.unix.shell/BIR9dDgKZvg [2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html src/dash.1 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/dash.1 b/src/dash.1 index 693c970..832eae7 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -1402,14 +1402,9 @@ By specifying a colon as the first character of .Va optstring all errors will be ignored. .Pp -A nonzero value is returned when the last option is reached. -If there are no remaining arguments, +After the last option .Ic getopts -will set -.Va var -to the special option, -.Dq -- , -otherwise, it will set +will return a non-zero value and set .Va var to .Dq \&? .