From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 08 08:40:04 2021 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 To: bug-guix@gnu.org Subject: CLI: short-name option with optional argument 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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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: <