On Mon, Apr 21, 2025 at 01:59:25PM +0200, Tomas Rippl wrote:
> Hello,
>
> While studying the `ksh(1)` manual on OpenBSD 7.6,
> I noticed that the example under the "case" statement section reads:
>
> ?? case $foo { *) echo bar; }
>
> This example technically works only because the pattern-action pair
> is the final (and only) one, and thus the terminating `;;` is optional
> in this specific case.
>
> However, I believe the example may be slightly misleading
> for readers who might assume that a single semicolon is always sufficient.
> A more robust example might include the `;;`, and perhaps
> a short note could clarify that the semicolon(s) are optional **only**
> after the final pattern.
>
> Suggested change:
>
> ?? case $foo { *) echo bar ;; }
>
> And/or add a line like:
>
> ?? Note that `;;` is required between pattern-action pairs,
> but may be omitted or replaced with a single semicolon
> on the final pattern.
>
> I???m a beginner and amateur user who???s currently just learning
> and playing with OpenBSD, and I truly appreciate the clarity
> and consistency of the documentation. Just wanted to try
> and give a small contribution in return.
>
> Thank you for your great work.
>
> Best regards,??
> Tom
>
hi!
next step is submitting a diff. there is a section in the excellent faq
("Preparing a Diff") for guidance.
anyway, to address your issue... i'm not sure if there is a reason why
this isn;t documented. i went for a minimal fix and just lifted the
corresponding line from sh(1). i decided not to alter the example
because a) "it's aye been" and b) nothing wrong with making people read
the text.
here's what i propose:
Index: ksh.1
===================================================================
RCS file: /cvs/src/bin/ksh/ksh.1,v
diff -u -p -r1.221 ksh.1
--- ksh.1 25 Sep 2024 06:13:01 -0000 1.221
+++ ksh.1 22 Apr 2025 10:38:44 -0000
@@ -528,6 +528,13 @@ stripped; any space within a pattern mus
Both the word and the
patterns are subject to parameter, command, and arithmetic substitution, as
well as tilde substitution.
+The initial
+.Sq (\&
+is optional,
+as is the terminating
+.Sq ;;
+for the final
+.Ar list .
For historical reasons, open and close braces may be used instead of
.Cm in
and