CLI: short-name option with optional argument

OpenSubmitted by zimoun.
One participant
  • zimoun
zimoun wrote on 8 Sep 14:38 +0200
(address .
The help says, for example:
Toggle snippet (6 lines) -I, --list-installed[=REGEXP] list installed packages matching REGEXP -A, --list-available[=REGEXP] list available packages matching REGEXP
and the manual also says:
Toggle snippet (11 lines)‘--list-installed[=REGEXP]’‘-I [REGEXP]’ List the currently installed packages in the specified profile,
‘--list-available[=REGEXP]’‘-A [REGEXP]’ List packages currently available in the distribution for this
which is not true. The ’REGEXP’ is not optional when using theshort-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
Here, the issue is illustrated with 2 options but it happens for all theoptions allowing an optional-argument *and* a short-name. Exhaustivelist: guix gc: -C, --collect-garbage[=MIN] -d, --delete-generations[=PATTERN]
guix package: -u, --upgrade[=REGEXP] -l, --list-generations[=PATTERN] -d, --delete-generations[=PATTERN] -I, --list-installed[=REGEXP] -A, --list-available[=REGEXP]
guix pull: -l, --list-generations[=PATTERN] -d, --delete-generations[=PATTERN]
guix weather: -c, --coverage[=COUNT]
guix publish: -C, --compression[=METHOD:LEVEL] -r, --repl[=PORT] créer le serveur REPL sur le PORT
And “guix {system,import,git}” needs some special care. :-)

The issue is that the semantic of short-name of optional argument isambiguous considering all the other rules.
All is correctly documented, for instance see SRFI-37 [1]. What ismissing is the corner case: how to deal with short-name option withoptional argument? There is 2 incompatible rules. The choice of theGuile implementation leads to break the permutation rule for theshort-name with optional argument and maintain consistency with thespace between flag and argument. Another choice is to break theconsistency with the space between flag and argument and so it does notbreak the permutation rule; as with the Git example of '-S[<keyid>],--gpg-sign[=<keyid>]'.
Using optional argument with short-option names is unusual, AFAIK. Andfor sure, there is an ambiguity; as we are seeing here. :-) However, theonly mention of that is in the commentaries of Guile implementation ofsrfi-37 [2].
Toggle snippet (9 lines);;; `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.
Well, using short-option with optional-argument is not recommended byPOSIX [3], neither GNU [4] (if I understand well).
The question is what do we do? For reference, the issue had beenreported 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 usinga 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 ’-I’ meaning’--list-installed’ with the current default REGEXP.

All the best,simon
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to