From nobody Sat Jun 20 19:03:15 2026 X-Original-To: dev-commits-src-branches@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 4gjP4M54Fpz6hNDW for ; Sat, 20 Jun 2026 19:03:15 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gjP4M1pSLz3rCX for ; Sat, 20 Jun 2026 19:03:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781982195; 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=qBYqcI8ms0e5cmR1v59+TsCVVOhVM3WSPBi0mlr7RKg=; b=AcDbH6bfHzZpWjNVJtvcdLJHPHMWm7/ZqDAIA+S/xwWjPGAnGlNeNN4Ib6xleubGmzWlaC cYZT/WxVBBPEeZ6qLnwTGvfAnRe7tUgONBBV4vD0WtMLH6Wq4rxP6FM83YAuvscKYOcXor 2mUppkZjPJWxIfBvJOmgqtk5/uqVvlXwZZCqvoLZ8hvijVzxK4/jIp42XY3gXbsRIO5kx8 DPRl5bfW9zDShS7Q37jII1AyYxuWsEcBhnrcwzT/xOMEqshsW6limx0nDLBGUWiyWuRAZi SjjvR8sF8IoYBDN+JH9iGp/QEMyRHhyqlvUh06MkrlE+bKKVGnHM7FKFwlVFiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781982195; a=rsa-sha256; cv=none; b=u/QuJPNA02UjQKyoqIMpFVCE4909IoQ8OFwZJLKDl1899wgAZ8oU9BkxsAgKa60vMrfMzt 8TbUGLU89XySOL9XfGb7oY/PmFaHvok5vHvcdHv0zVLZLPF4c80zuPgWB30KASp72Q7UF5 Jwr2sFK8/l2RrMqY6W/Nd8v53s4tfoRg2gvO3u/UrE4I/+ilXKPdo2d6I35NPv5qkFuUED /qx+IVSTg/WZ92c/wCuQMKgnU1ix+2dZjLz/meKhQ84G7Qe4bUZaHG1TDvlL09/HT174GO gQDax4oSgZP3tghQ+5Vk07eKvhOolivXSoaTO+ljN4ceR5PmNsMbAToG6oEdzQ== 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=1781982195; 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=qBYqcI8ms0e5cmR1v59+TsCVVOhVM3WSPBi0mlr7RKg=; b=IQYDohkUbcMQIh9X0gQqllI/efd2eabQLwHR8Q4fom5BJDrXnkFs1njDR3e7b+4n0WpWx9 LLnGjr4Uj00YThlix+LRM9saWfHoNw1Nfmhee40wsullIeKSbQTyS/8oWnX6XGIHK01qvi zKaN1JilS2hzYX5TpfF074e/hQyJH/AB0GJyhFTJN5zj8z+hUVsB8E8t/QIQbuL0yI0N0P o26R7FMbqLVN4ebHiuGzbs4vEehTSRAr/Pr7wu3vtDDSYSlPtthSCFhhqCUYlQVE1SvfgG ZUdof47jUC8puIms4d51Zic24kfTTBPYoa/SNWTwo7AAgCOsTmjhKPGEnJYjVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gjP4M0g3QzkLd for ; Sat, 20 Jun 2026 19:03:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3339f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 20 Jun 2026 19:03:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: ea13334abd9f - stable/15 - sh: Improve function documentation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/15 X-Git-Reftype: branch X-Git-Commit: ea13334abd9f4ed5456ba58970ee426a48c9c8e6 Auto-Submitted: auto-generated Date: Sat, 20 Jun 2026 19:03:15 +0000 Message-Id: <6a36e3f3.3339f.df30644@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=ea13334abd9f4ed5456ba58970ee426a48c9c8e6 commit ea13334abd9f4ed5456ba58970ee426a48c9c8e6 Author: Dag-Erling Smørgrav AuthorDate: 2026-06-16 20:23:18 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-06-20 19:02:47 +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 (cherry picked from commit 556e793d803e12e9ad9361c6c53ed0433151f41e) sh: Belatedly bump manual page date Fixes: 556e793d803e ("sh: Improve function documentation") (cherry picked from commit 09bb0b0d13968163c7394e9168491b16607fc2e7) --- bin/sh/sh.1 | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 4f860d89c654..a19aa7459896 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -41,7 +41,7 @@ .\" the referee document. The original Standard can be obtained online at .\" http://www.opengroup.org/unix/online.html. .\" -.Dd February 17, 2026 +.Dd June 16, 2026 .Dt SH 1 .Os .Sh NAME @@ -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.