From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qLASIW2vOGEcuwAAgWs5BA (envelope-from ) for ; Wed, 08 Sep 2021 14:41:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4LDjHG2vOGGsYgAAbx9fmQ (envelope-from ) for ; Wed, 08 Sep 2021 12:41:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8F5321626E for ; Wed, 8 Sep 2021 14:41:16 +0200 (CEST) Received: from localhost ([::1]:54092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNwt8-00071k-JN for larch@yhetil.org; Wed, 08 Sep 2021 08:41:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNwsw-0006zd-6q for bug-guix@gnu.org; Wed, 08 Sep 2021 08:41:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNwsv-0003uG-Uc for bug-guix@gnu.org; Wed, 08 Sep 2021 08:41:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mNwsv-0001kE-T7 for bug-guix@gnu.org; Wed, 08 Sep 2021 08:41:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#50472: CLI: short-name option with optional argument Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 08 Sep 2021 12:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50472 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 50472@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16311048046625 (code B ref -1); Wed, 08 Sep 2021 12:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Sep 2021 12:40:04 +0000 Received: from localhost ([127.0.0.1]:58857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNws0-0001im-6P for submit@debbugs.gnu.org; Wed, 08 Sep 2021 08:40:04 -0400 Received: from lists.gnu.org ([209.51.188.17]:55912) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNwrw-0001iI-I8 for submit@debbugs.gnu.org; Wed, 08 Sep 2021 08:40:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNwrw-0005ps-8m for bug-guix@gnu.org; Wed, 08 Sep 2021 08:40:00 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:40550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNwrt-0003AS-3r for bug-guix@gnu.org; Wed, 08 Sep 2021 08:39:59 -0400 Received: by mail-wm1-x335.google.com with SMTP id n14-20020a05600c3b8e00b002f8bd2f8ab6so1483312wms.5 for ; Wed, 08 Sep 2021 05:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=hccafTFa1PJeRuvCCOgLPqE9235gJC4+g2d0aldNMzo=; b=nMBSPefyCp6wQXEccHjtmIAytMccUnvkC8KFAVM3dzQsExz2OYM8umtRXx6IlmaWEg d2E+uwSclbSDzQTzTSejdY+gHJd+D29iE8MY7fklWUwNNneIFRk8zybPRaVmnz4S9XCW qw9vcDSRQ5Ih7/oroDfSCw13jWfMmtm1INTBWCvSdzP1+yEpCjUVbSXJmgQWWpr86/aE wSI9LlzsFJ4UJW70tn5tqW063+n/6BdZqNIIpWvyH92iC/ecLDY1frCRAnVHhkw5hJVm RvGr9D5w8qfHThpusqzl1EHtKuPlOKtde6KRN/i4Bl0E0X+chZi2NcEhxB9IoepXHzHK N+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=hccafTFa1PJeRuvCCOgLPqE9235gJC4+g2d0aldNMzo=; b=I4LQIF0BrUoyw7gO9we9Cea/IujUXyGo9UTnb4C3Yp2VXHUAdj48kuLwizv9FhPO2X CXy5Qt5+FmaOQl5dE/C/vfPq5wpGiVqzRDW0GX15Jk8JCwBah7JwXQvqtCX48B4K/EV5 Q0z2ivolbERoQLvRzw4yPHB5ljMdPZ7MaTppL89IQIrBdSS6Q9oEyol/hxlMG5LI+GEP 1rTC3Me0x0UFtWghEYM8wFJAmt/UAm0obEjGSDmqsVSYL3MpSYDfaQnu4HdGcN4Y1Cgi dvZuBUVWqBEgq5SyRDaLHAQCYg9Be2wvl60imqqBjq6xbgxH8L6QVYgyrvhv2jCrkEBp cvxw== X-Gm-Message-State: AOAM530/vRXSG29nlI4CnIraoJage6P+HSmb+Q/ftjCLfNqtsjGKwAE7 oDKeY/Uxr5Yiwi66M8JqO5KBZyOJXSA= X-Google-Smtp-Source: ABdhPJyzi8Eis7AgNAT9c0ecMmfnCLKikibDdc1KYZsld2ZRpN9SctodRypdEys2MAGuN8tPTWUq7A== X-Received: by 2002:a1c:7c12:: with SMTP id x18mr3490100wmc.114.1631104795426; Wed, 08 Sep 2021 05:39:55 -0700 (PDT) Received: from jack-Precision-7820-Tower ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id y4sm1963564wmi.22.2021.09.08.05.39.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 05:39:55 -0700 (PDT) From: zimoun Date: Wed, 08 Sep 2021 14:38:40 +0200 Message-ID: <865yvb2qen.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=zimon.toutoune@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631104877; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=hccafTFa1PJeRuvCCOgLPqE9235gJC4+g2d0aldNMzo=; b=Q2vwNec2fswV3FI7pxzYe4XCznds+k+tVvGN7DXrW1iRmJVtPC6iof0asqVe5nu05xMGnA BXGkGDiJSsFK2jhLAaCv4HtLqKBx62GNYH59EMwXewJZnSv0DekJiO7OjY6Cl3/PYowEEx IlbOZK5UbCmaLqRpuubD+Q1VEoufkoH3N0BjaHFNXdk6C7ZAhIW5WQB7QcL42OBvU/hHnL MKQoI4L1AVh/zODTbnVpdBQZrA6qNDzebvKmibWaMen+XV+a3qXzhm/aXTVix/oW9I8eSw 8XlRpbe2KVUNG7SOndPPDigHQao+tSkCQFqrYtMC7fCpyaEQidb4c1XNjzg9qw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631104877; a=rsa-sha256; cv=none; b=UsBV4zAqG4L3gjyM2Wc7Lpdo39VV+6KCK1N+DiBjdWfQEUYX0T69ggRYyUO9prKe7+Ccd/ 09V9vyqVMTdfLgtKgko0NW89ZkLcgMO4tYGJ4hV3q6L5uQpN8C53sbOZ+scaXI9QlTgc3x nC1zoMmIeplW2KYNzZ4awn9lR3R1OOY4jOqf7uiTuum+Iqk1HMOtUBYR/3SS9jVMoIt7tI r274TTsb1UvYkqY/xrlszin7RMUFD7SxYyS3Axl5r20ndVGNljdqtEPjXqIaSv1o68ObAD 9cnjI1v5yGNkgenaP1bCCKiSP1dlgABz1BaLC4FrmsNhoGcfhtS+U0X5pKYP1w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=nMBSPefy; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -1.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=nMBSPefy; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 8F5321626E X-Spam-Score: -1.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: o8gQvqZZO7OZ Hi, The help says, for example: --8<---------------cut here---------------start------------->8--- -I, --list-installed[=3DREGEXP] list installed packages matching REGEXP -A, --list-available[=3DREGEXP] list available packages matching REGEXP --8<---------------cut here---------------end--------------->8--- and the manual also says: --8<---------------cut here---------------start------------->8--- =E2=80=98--list-installed[=3DREGEXP]=E2=80=99 =E2=80=98-I [REGEXP]=E2=80=99 List the currently installed packages in the specified profile, [...] =E2=80=98--list-available[=3DREGEXP]=E2=80=99 =E2=80=98-A [REGEXP]=E2=80=99 List packages currently available in the distribution for this --8<---------------cut here---------------end--------------->8--- which is not true. The =E2=80=99REGEXP=E2=80=99 is not optional when using= the short-name option. For instance, consider: $ guix package -I -p ~/.guix-profile guix package: error: /home/simon/.guix-profile: extraneous argument $ guix package -A -p ~/.guix-profile guix package: error: /home/simon/.guix-profile: extraneous argument And compare with: $ guix package --list-installed -p ~/.guix-profile $ guix package --list-available -p ~/.guix-profile =20 Here, the issue is illustrated with 2 options but it happens for all the options allowing an optional-argument *and* a short-name. Exhaustive list: guix gc: -C, --collect-garbage[=3DMIN] -d, --delete-generations[=3DPATTERN] guix package: -u, --upgrade[=3DREGEXP] -l, --list-generations[=3DPATTERN] -d, --delete-generations[=3DPATTERN] -I, --list-installed[=3DREGEXP] -A, --list-available[=3DREGEXP] guix pull: -l, --list-generations[=3DPATTERN] -d, --delete-generations[=3DPATTERN] guix weather: -c, --coverage[=3DCOUNT] guix publish: -C, --compression[=3DMETHOD:LEVEL] -r, --repl[=3DPORT] cr=C3=A9er le serveur REPL sur le PORT And =E2=80=9Cguix {system,import,git}=E2=80=9D needs some special care. :-) The issue is that the semantic of short-name of optional argument is ambiguous considering all the other rules. All is correctly documented, for instance see SRFI-37 [1]. What is missing is the corner case: how to deal with short-name option with optional argument? There is 2 incompatible rules. The choice of the Guile implementation leads to break the permutation rule for the short-name with optional argument and maintain consistency with the space between flag and argument. Another choice is to break the consistency with the space between flag and argument and so it does not break the permutation rule; as with the Git example of '-S[], --gpg-sign[=3D]'. Using optional argument with short-option names is unusual, AFAIK. And for sure, there is an ambiguity; as we are seeing here. :-) However, the only mention of that is in the commentaries of Guile implementation of srfi-37 [2]. --8<---------------cut here---------------start------------->8--- ;;; `required-arg?' and `optional-arg?' are mutually exclusive ;;; booleans and indicate whether an argument must be or may be ;;; provided. Besides the obvious, this affects semantics of ;;; short-options, as short-options with a required or optional ;;; argument cannot be followed by other short options in the same ;;; program-arguments string, as they will be interpreted collectively ;;; as the option's argument. --8<---------------cut here---------------end--------------->8--- Well, using short-option with optional-argument is not recommended by POSIX [3], neither GNU [4] (if I understand well). The question is what do we do? For reference, the issue had been reported by bug#40549 [5]. The short-name option with no argument is handy, for instance: $ guix package -A | cut -f1 | grep cuirass $ guix weather $(guix package -I | cut -f1) but breaking the permutation is *really* annoying; especially when using a lot of profiles. Therefore, I propose: 1) remove the short-name with optional argument; keep the long-name with optional argument 2) add a short-name without argument; for example =E2=80=99-I=E2=80=99 mean= ing =E2=80=99--list-installed=E2=80=99 with the current default REGEXP. WDYT? All the best, simon 1: 2: 3: 4: 5: <