Page MenuHomeFreeBSD

sh: Improve function documentation
ClosedPublic

Authored by des on Mon, Jun 15, 12:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jun 25, 8:53 AM
Unknown Object (File)
Thu, Jun 25, 8:16 AM
Unknown Object (File)
Thu, Jun 25, 8:12 AM
Unknown Object (File)
Tue, Jun 23, 8:48 AM
Unknown Object (File)
Sun, Jun 21, 8:21 PM
Unknown Object (File)
Fri, Jun 19, 2:06 AM
Unknown Object (File)
Thu, Jun 18, 7:47 PM
Unknown Object (File)
Thu, Jun 18, 7:32 PM
Subscribers

Details

Summary
  • Mention that the function body can be in parentheses. It is already implied since the function body can be any valid statement, but it may not be obvious to a reader who has only ever seen functions that used curly brackets and assumes that they are part of the function syntax.
  • Remove the incorrect claim that a local statement may only occur at the top of a function.
  • Show that a value may be assigned to a variable in a local statement.
  • While here, replace unpaired double quotes with \(dq to avoid confusing syntax highlighters.

PR: 296050
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Mon, Jun 15, 12:45 PM

LGTM from manpages modulo the suggestion to use the roff parenthesis escape instead of escaping the parenthesis. Thanks for doing this!

bin/sh/sh.1
1169–1171
This revision is now accepted and ready to land.Mon, Jun 15, 1:04 PM
des marked an inline comment as done.Mon, Jun 15, 2:15 PM
des added inline comments.
bin/sh/sh.1
1169–1171

The mandoc_char(7) manual page explicitly warns against using \*(lp and \*)rp. Also, \& is not an escape, it is a zero-width space which prevents mandoc from interpreting the parentheses as punctuation and rendering them as ''( and '') instead of '(' and ')'.

bin/sh/sh.1
1169–1171

The mandoc_char(7) manual page explicitly warns against using \*(lp and \*)rp

Oops, I missed that, thanks.

des marked 2 inline comments as done.Tue, Jun 16, 12:58 AM
jilles added inline comments.
bin/sh/sh.1
1168–1173

OK. For that other review about extensions to POSIX, note that POSIX requires the command to be a compound command. For example, f() echo hi is not POSIX-compliant application code, does not work in bash but does work in most other shells (including our sh).

However, for this review there is no need to change anything.

des marked an inline comment as done.Tue, Jun 16, 8:22 PM
des added inline comments.
bin/sh/sh.1
1168–1173

I have no idea what other review you are talking about. I only have this one.

des marked an inline comment as done.Tue, Jun 16, 8:22 PM
This revision was automatically updated to reflect the committed changes.