Summary: | bectl(8) usage: -? | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Graham Perrin <grahamperrin> | ||||
Component: | bin | Assignee: | Dag-Erling Smørgrav <des> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Some People | CC: | des, kevans, pat, tatsuki_makino | ||||
Priority: | --- | Flags: | des:
mfc-stable14+
des: mfc-stable13+ |
||||
Version: | CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
URL: | https://reviews.freebsd.org/D44405 | ||||||
Attachments: |
|
Description
Graham Perrin
2023-06-28 02:37:09 UTC
> bectl: No match.
That message is going to be coming from your shell somewhere, not bectl.
```
root@aarch64-dev:/usr/src/sbin/bectl# bectl -?
zsh: no matches found: -?
root@aarch64-dev:/usr/src/sbin/bectl# bectl -\?
Usage: bectl {-h | -? | subcommand [args...]}
bectl [-r beroot] activate [-t] beName
bectl [-r beroot] activate [-T]
bectl [-r beroot] check
bectl [-r beroot] create [-r] [-e {nonActiveBe | beName@snapshot}] beName
bectl [-r beroot] create [-r] beName@snapshot
bectl [-r beroot] destroy [-Fo] {beName | beName@snapshot}
bectl [-r beroot] export sourceBe
bectl [-r beroot] import targetBe
bectl [-r beroot] jail [-bU] [{-o key=value | -u key}]... beName
[utility [argument ...]]
bectl [-r beroot] list [-aDHs] [{-c property | -C property}]
bectl [-r beroot] mount beName [mountpoint]
bectl [-r beroot] rename origBeName newBeName
bectl [-r beroot] {ujail | unjail} {jailID | jailName | beName}
bectl [-r beroot] {umount | unmount} [-f] beName
```
I don't know if I really agree with supporting -? as a synonym for -h, but that's the way it's been since I imported it and I don't see any reason to remove it.
(In reply to Kyle Evans from comment #1) I suspect you are using csh, because while "match" doesn't appear anywhere outside of comments in bectl / libbe, there is a literal match in csh: https://cgit.freebsd.org/src/tree/contrib/tcsh/sh.err.c#n262 Thanks, (In reply to Kyle Evans from comment #2) > I suspect you are using csh, … True. I temporarily used sh, then -? became usable. Is it commonplace for utilities to allow -? as an alternative to -h? Incidentally, > SYNOPSIS > bectl [-h?] – should that have a vertical line? So: > SYNOPSIS > bectl [-h | ?] (Now I remember, <https://github.com/freebsd/freebsd-src/pull/728/commits/f6f931d28b2d7c231317e52df641f15ef49042f3#diff-c02d05827bafa5f8205b59bd5e53274a6043030b432b47ffcb9bb7907bb5d5f5R26-R28> I could not figure out the markup to achieve it.) (In reply to Graham Perrin from comment #4) (Anyone can answer the | / markup questions …) In any shell, using -? options requires more typing by escaping or quoting like -\?, '-?' or "-?". (In reply to Graham Perrin from comment #4) They're synonyms but they are in-fact mutually exclusive, so they would need a vertical bar. You'll get confusing output if you try to do `bectl -\?h` because we don't use getopt(3) here; it's just a couple of hand-rolled strcmp() since there's only all of three options (-h, -?, -r) and two of them are synonyms anyways. (In reply to Kyle Evans from comment #7) > because we don't use getopt(3) here; I've thought it would be better to document whether getopt or getopt_long are used. On rare occasions I want to know if -- can indicate the end of an option flag. Although it is a very, very rare case :) Created attachment 243051 [details]
format -h|-? properly
Format -h|-? properly; also get rid of Xo where it's not really needed, fixing mandoc lint.
Comment on attachment 243051 [details]
format -h|-? properly
I think, there should be a space either side of the vertical line.
(Elsewhere in the page, comparable uses of a vertical line do have spaces.)
Because `getopt(3)` returns `?` when it encounters an error, and the usual way to handle said error is to print a usage message and exit, `-?` can usually be relied upon to produce a usage message even if the author of the utility did not think to provide a `-h` option for that purpose. Some people have improperly internalized this as “`-?` is the standard way to request a usage message”, which is not the case. The author of `bectl(8)` appears to be one of those people, and hardcoded a check for `-?` in `bectl(8)`'s non-standard command line parser. My recommendation is to rewrite `bectl(8)` to use `getopt(3)` and remove all mention of `-?` from the usage string and manual page. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e819534f15308c92afd19166254604995766ce32 commit e819534f15308c92afd19166254604995766ce32 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2024-03-18 13:49:18 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2024-03-18 13:49:18 +0000 bectl: Use geopt() and drop mention of -?. MFC after: 3 days PR: 272260 Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44405 sbin/bectl/bectl.8 | 9 ++++----- sbin/bectl/bectl.c | 45 +++++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 27 deletions(-) A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=98a9731683696b615b5a94a483aa73a9b418791d commit 98a9731683696b615b5a94a483aa73a9b418791d Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2024-03-18 13:49:18 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2024-03-22 08:07:03 +0000 bectl: Use geopt() and drop mention of -?. MFC after: 3 days PR: 272260 Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44405 (cherry picked from commit e819534f15308c92afd19166254604995766ce32) sbin/bectl/bectl.8 | 9 ++++----- sbin/bectl/bectl.c | 45 +++++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 27 deletions(-) A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=95d66df41b832724a6a5e58f4a07cc89639cb660 commit 95d66df41b832724a6a5e58f4a07cc89639cb660 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2024-03-18 13:49:18 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2024-03-22 08:07:34 +0000 bectl: Use geopt() and drop mention of -?. MFC after: 3 days PR: 272260 Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44405 (cherry picked from commit e819534f15308c92afd19166254604995766ce32) sbin/bectl/bectl.8 | 11 ++++------- sbin/bectl/bectl.c | 45 +++++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 29 deletions(-) |