Compare beep(1) to the usage message `beep -h`: > Usage: beep [parameters] > -F <frequency in HZ, default 440 Hz> > -D <duration in ms, from 50 ms to 2000 ms, default 150 ms> > -r <sample rate in HZ, from 8000 Hz to 48000 Hz, default 48000 Hz> > -d <OSS device (default /dev/dsp)> > -g <gain from 0 to 100, default 75> > -B Run in background > -h Show usage Source: https://github.com/freebsd/freebsd-src/blob/main/usr.bin/beep/beep.c This output is generated from DEFAULT_HZ, DURATION_MIN, DURATION_MAX, DURATION_DEF, SAMPLE_RATE_MIN, SAMPLE_RATE_MAX, SAMPLE_RATE_DEF, DEFAULT_DEVICE, GAIN_MIN, GAIN_MAX, and GAIN_DEF so stated figures match the code's behavior. A supplied value for duration, sample rate, or gain that is below min or above max results in exit status 1. No min or max is applied for frequency. The beep(1) "Description" section states correct defaults for -F, -D, -d, -r, and -g but not the min and max permissible values for -D, -r, and -g. The order with -d followed by -r is swapped both in comparison to the usage message and the "Synopsis", where -r comes before -d. Also, several sentences have a space before the period, including one in "Examples" ("Playback default beep sound using /dev/dsp .") which should probably end in a colon instead.
Proposed fixes: https://reviews.freebsd.org/D53827
(In reply to Jose Luis Duran from comment #1) Thanks, this is much better! Commenting here as I do not have a Phabricator account: All dictionaries and references I checked list "sample rate" as two words separated by a space, and not as a single word or hyphenated. So "samplerate" in the man page should be "sample rate" like in the usage message. In the usage message, there's an inconsistency between "<OSS device (default %s)>" with parenthesized default, and the way other defaults are given after a comma like "<frequency in Hz, default %d Hz>".
Resetting the status since the patch hasn't landed in main yet.
Re whether the usage message is redundant to the man page: it has a different role. The usage message is printed to stderr after an impermissible input (e.g. duration below min or above max). For comparison, ministat(1) has an extensive usage message but it only appears after an erroneous input (no `-h` flag to invoke it deliberately). Nicely, this is accompanied by a statement of what triggered the error: `ministat -c 71` reports "No support for confidence level", then the usage message. This would be nice to have on beep(1) too, but wasn't part of my Problem Report. See: https://man.freebsd.org/cgi/man.cgi?ministat https://github.com/freebsd/freebsd-src/blob/main/usr.bin/ministat/ministat.c Arguably, when deliberately invoked by `beep -h`, perhaps the usage message should be printed to stdout instead of stderr, but practice on that is not universal and I don't know what the norm is in FreeBSD. See e.g. https://stackoverflow.com/questions/2199624/should-the-command-line-usage-be-printed-on-stdout-or-stderr
(In reply to B.S. from comment #4) I agree with most of the comments described here. Regarding the file descriptor of "-h" (stdout or stderr), I also agree, that -h should output usage() to stdout. But I would prefer this change be implemented as part of an effort to standardize all non-contributed utilities (preferably with tests). I think there are a few utilities in base that pre-date the notion of "-h" standing for "help".
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=55d98b024f25403f60efe04f90a391014b6bc388 commit 55d98b024f25403f60efe04f90a391014b6bc388 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-11-19 15:59:25 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-11-22 17:28:46 +0000 beep: Sort usage and man page options Sort usage and man page options, mention possible minimum and maximum values, fix punctuation marks, and cleanup the man page. PR: 291092 Reviewed by: pauamma_gundo.com, christos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53827 usr.bin/beep/beep.1 | 55 ++++++++++++++++++++++++++++------------------------- usr.bin/beep/beep.c | 19 +++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=6bda3655b8272aa9fd1301df3346aca4d5b0d39c commit 6bda3655b8272aa9fd1301df3346aca4d5b0d39c Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-11-19 15:59:25 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-11-29 00:30:21 +0000 beep: Sort usage and man page options Sort usage and man page options, mention possible minimum and maximum values, fix punctuation marks, and cleanup the man page. PR: 291092 Reviewed by: pauamma_gundo.com, christos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53827 (cherry picked from commit 55d98b024f25403f60efe04f90a391014b6bc388) usr.bin/beep/beep.1 | 55 ++++++++++++++++++++++++++++------------------------- usr.bin/beep/beep.c | 19 +++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4c10ec9bd43feb86394dc2dc1c16f1c15d4b0285 commit 4c10ec9bd43feb86394dc2dc1c16f1c15d4b0285 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-11-19 15:59:25 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-11-29 00:31:57 +0000 beep: Sort usage and man page options Sort usage and man page options, mention possible minimum and maximum values, fix punctuation marks, and cleanup the man page. PR: 291092 Reviewed by: pauamma_gundo.com, christos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53827 (cherry picked from commit 55d98b024f25403f60efe04f90a391014b6bc388) usr.bin/beep/beep.1 | 55 ++++++++++++++++++++++++++++------------------------- usr.bin/beep/beep.c | 19 +++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8d338f99f8b1dc16d2175721c48201fce117fe43 commit 8d338f99f8b1dc16d2175721c48201fce117fe43 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-11-19 15:59:25 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-11-29 00:32:36 +0000 beep: Sort usage and man page options Sort usage and man page options, mention possible minimum and maximum values, fix punctuation marks, and cleanup the man page. PR: 291092 Reviewed by: pauamma_gundo.com, christos MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53827 (cherry picked from commit 55d98b024f25403f60efe04f90a391014b6bc388) usr.bin/beep/beep.1 | 55 ++++++++++++++++++++++++++++------------------------- usr.bin/beep/beep.c | 19 +++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-)
Thank you for the bug report and review!