From nobody Tue Jun 16 20:23:46 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gfz365Dbcz6hlrb for ; Tue, 16 Jun 2026 20:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gfz364lxxz3fmB for ; Tue, 16 Jun 2026 20:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781641426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2X6DmIgdQy/UCmtbq/oVBBhl07/1Y6gNq9lesU7AI7s=; b=XzETxiZEI5t09MWi+DoB43Ia0gINg98HH6mr3K4zA175aFHzqIYSl1j+8nKATceqkcrR4W 99zG79GC2KHWl/ZNXqvYtEXOfGk3V8H9FIFqHzfjZFoDQILqL5YdTEejXNMT93rm5NFWjz LA1P2shKn745gaXOiZbSQGfLrBpW1ffMT6WTW5ahB6klEP0eIBE17V/NOC86FfodW7LEA9 EMYwHfGixwb+RoYkGAuhwpwg5ReytXE+/cIyBfuRm2Jyf/kdeqjAub5jVjVJZ80/CeXlRt LTxmx0+96b77fUXoU3/riQ0klVQCPbuOfx24WYl2vK5cgZao+O8EREm624ycBQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781641426; a=rsa-sha256; cv=none; b=TWjIH1ERZ/EK9LF5fV2Aao5Y7CIVxB5+EsBWPZTXZ3S7VxFplYqoDcG7Wx6wG2ABKPhGTT tS8m0yoXScWzdjB5/0simgWJIYGtfI1OIbIuVJjRUmdtz6CyqfoNR2fCLgVxJEux+tyT87 pcNlgXX/tb82UIs6RMQBZ/uVpkepevOhKq3psG0dLZbMK2hpOpwYfzRv8OpBqfwHUNNt/1 6hLX2HAOmTNHuwVohiM+zM5n6ZeIF8YgDYlTFwEq3etwUJ7EQjxPF33K5ohezUbr/KOnG7 nkaICFnodd0gCJ3S9Ol8QxKd+RN9nUAZy48uAafY5uJHVw2GlFkyRZql1CwdWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781641426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2X6DmIgdQy/UCmtbq/oVBBhl07/1Y6gNq9lesU7AI7s=; b=CJcB/A4tf7OQhuy4Q5HX/IdR/RQOVrNjaDLSp7F8tg0RSQ5C4As1RWiWn9OiA2cnl6B/St BoD72qv/FVHNcMRSccdfgXXTPmJ4QqOxW/d9u7eTjEV2x4GCvVu4KtLM+apwhFIvMZl0NJ b8MWdkmvUdKQ/lAQy/WbZ1xfwONPsMZo0fnMI+DraqMNI5yMSycZpNX0GBhbf2WgyAa6ef lPW9YKc5KCjX72hDN4g6TPLh9e43x87fS1ZrSUWLWwJE9dYduhRbh3DrpevCQLyABd9+hG TRyXvUz1n6YFm9EaedODqVw6A2ScugDfV7v6pJDTCq3+34bfi1vr9kTk3C6obw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gfz36429FzhnQ for ; Tue, 16 Jun 2026 20:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 38e9d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 16 Jun 2026 20:23:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 556e793d803e - main - sh: Improve function documentation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 556e793d803e12e9ad9361c6c53ed0433151f41e Auto-Submitted: auto-generated Date: Tue, 16 Jun 2026 20:23:46 +0000 Message-Id: <6a31b0d2.38e9d.aa8215c@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=556e793d803e12e9ad9361c6c53ed0433151f41e commit 556e793d803e12e9ad9361c6c53ed0433151f41e Author: Dag-Erling Smørgrav AuthorDate: 2026-06-16 20:23:18 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-06-16 20:23:18 +0000 sh: Improve function documentation * 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 Reviewed by: ziaee, jilles Differential Revision: https://reviews.freebsd.org/D57596 --- bin/sh/sh.1 | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 4f860d89c654..e76ddc80187a 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -487,7 +487,7 @@ Vertical tab Literal backslash .It \e\&' Literal single-quote -.It \e\&" +.It \e\(dq Literal double-quote .It \e Ns Ar nnn The byte whose octal value is @@ -529,7 +529,7 @@ It remains literal unless it precedes the following characters, which it serves to quote: .Pp .Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact -.It Li $ Ta Li ` Ta Li \&" Ta Li \e Ta Li \en +.It Li $ Ta Li ` Ta Li \(dq Ta Li \e Ta Li \en .El .It Backslash A backslash preserves the literal meaning of the following @@ -1164,16 +1164,20 @@ is normally a list enclosed between .Ql { and -.Ql } . +.Ql } +or +.Ql \&( +and +.Ql \&) . +In the latter case, the function will be executed in a subshell when +invoked. .Pp Variables may be declared to be local to a function by using the .Ic local -command. -This should appear as the first statement of a function, -and the syntax is: +command: .Pp -.D1 Ic local Oo Ar variable ... Oc Op Fl +.D1 Ic local Oo Ar variable Ns Oo = Ns value Oc ... Oc Op Fl .Pp The .Ic local @@ -1185,7 +1189,10 @@ When a variable is made local, it inherits the initial value and exported and readonly flags from the variable with the same name in the surrounding scope, if there is one. -Otherwise, the variable is initially unset. +Otherwise, the variable is initially unset unless assigned a value in +the +.Ic local +statement. The shell uses dynamic scoping, so that if the variable .Va x @@ -2637,7 +2644,7 @@ by means of specifying their job IDs as arguments. See .Sx Job Control for a list of job ID forms. -.It Ic local Oo Ar variable ... Oc Op Fl +.It Ic local Oo Ar variable Ns Oo = Ns value Oc ... Oc Op Fl See the .Sx Functions subsection.