From nobody Fri Jan 9 21:03:19 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 4dnvPh0cQmz6MN40 for ; Fri, 09 Jan 2026 21:03:20 +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" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dnvPg4ZyFz3Stt for ; Fri, 09 Jan 2026 21:03:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767992599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vrwVGtnISj6lKos3Fo8Olv5FUZwo9ElZk9AsS+ShDsQ=; b=oqENLL3fAQ+xG1OaEKT7umS/8NxUQ4VYyT5wn5USyAeFTNNIzsba9wTSuOVAnHs+WX/41y g+I089hJWwQj1sL6IZf1wBarf/jSoxGslcQQuLZ6itK6gofIkb9eK8qx4htSWNwpl5e/kO jUCfzg4aLTnnxZrmcIKLx3WQEGMyvp1RRot1PqCt5Tt5pI8PdeyzRmS2kJspZf6ylQRUTl ry5Pa2c/QDMyvuScsQx3NA1Ph37IxW7zT0f4xjejjbIx4WXeuomPRsEVrEgjBNe+MVSJcE Fef8xBsTvy+jLYD5pq574G1bgp0Y7EVzOizPm+myi5Dfp95IAJ9QfShy+Vdpgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767992599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vrwVGtnISj6lKos3Fo8Olv5FUZwo9ElZk9AsS+ShDsQ=; b=QxJo4HFytGuiO0FRzr0WeiLIAXGEh605mC53aAN6Cdgq8kvUELpEmHme2NxRjNJU0hGHSd L3emlgljoMiWR4bZrJyOQNhevyZEkki+opWS+OYC8j7ghcDb0TbEgAgSS7rP1KZPNB7BFO m4OFOnltsxK+59Rp6I+HzQbT4gnOUK641pLcSmRGccogj5tQ0leF/HCnB9re0Aks1iSr5R oco9U5JoqUfkOzhPfBlVsiBn2+YsfsUy38/Wf+bc+QUl9VNtWa4arp9zxvWapsuVe2RkhC zqr8CpIzV57B1b86GFRE9eckxqkrZjIHqmYWnzJ2tkzDREWZxZz1NbeBxLKqmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767992599; a=rsa-sha256; cv=none; b=j+rkXukP8vCAlEaUtu8PYeoGzierwuGHfH45UliJViVr/7eM5QH0XAO+WZHVghSiYIlBbE rF7TUpwewLWDUWWd1ZwZwFqwACo/g+5fJPAEOeDXS30yeqBzYaQyOboRh8aa41vA0WNY5N +Z51y4hWYTvOBwfnfkVegjJPX5GLAJfjvouUBOmohu63cRJY89cIpKnJUeJSASbwcXqU20 mUvyM7gzQvEserTe4uOiKzCKVuvCVFhrLWDM57SuPVJ2Z+kPmYqikciETok1t4AphqLDnb 8wYS9569Nsu+FeXQtyOD20d+xqxbEZACNjXfQsY6IWevXy5ghYZyQv7Ua8QG6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dnvPg2t8Jz8v6 for ; Fri, 09 Jan 2026 21:03:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id aa5b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 09 Jan 2026 21:03:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Simon Wollwage From: Warner Losh Subject: git: 4b2a8aab43ff - main - getopt(3): be more explicit about :: extension 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b2a8aab43ff747bcba6c28f5c0431141ec198a0 Auto-Submitted: auto-generated Date: Fri, 09 Jan 2026 21:03:19 +0000 Message-Id: <69616d17.aa5b.549e3dbb@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4b2a8aab43ff747bcba6c28f5c0431141ec198a0 commit 4b2a8aab43ff747bcba6c28f5c0431141ec198a0 Author: Simon Wollwage AuthorDate: 2025-12-12 05:11:40 +0000 Commit: Warner Losh CommitDate: 2026-01-09 21:02:23 +0000 getopt(3): be more explicit about :: extension Make it possible to search for literal two colons (::) and actually find something. Make the "x"/"x:"/"x::" examples more explicit and more visibile. Signed-off-by: Simon Wollwage Obtained from: NetBSD, nbuwe , 856d5b6 PR: 291374 Reviewed by: imp, jlduran Pull Request: https://github.com/freebsd/freebsd-src/pull/1923 --- lib/libc/stdlib/getopt.3 | 49 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3 index a5b5bff9d1a7..1b40f6dfea7e 100644 --- a/lib/libc/stdlib/getopt.3 +++ b/lib/libc/stdlib/getopt.3 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 5, 2014 +.Dd December 14, 2025 .Dt GETOPT 3 .Os .Sh NAME @@ -60,30 +60,49 @@ if it has been specified in the string of accepted option characters, The option string .Fa optstring may contain the following elements: individual characters, and -characters followed by a colon to indicate an option argument -is to follow. -If an individual character is followed by two colons, then the -option argument is optional; +characters followed by a colon +.Pq Ql \&: +to indicate an option argument is to follow. +If an individual character is followed by two colons +.Pq Ql \&:\&: , +then the option argument is optional; .Va optarg is set to the rest of the current -.Va argv +.Fa argv word, or .Dv NULL if there were no more characters in the current word. -This is a -.Tn GNU -extension. +This is an extension not covered by POSIX. +.Pp For example, an option string .Li \&"x" recognizes an option -.Dq Fl x , -and an option string +.Dq Fl x . +.Pp +An option string .Li \&"x:" -recognizes an option and argument -.Dq Fl x Ar argument . +recognizes an option with an argument, both +.Dq Fl x Ns Ar arg\^ , +and +.Dq Fl x Ar arg\^ . It does not matter to .Fn getopt -if a following argument has leading white space. +if the option's argument is a separate word or not. +.Pp +An option string +.Li \&"x::" +recognizes the option both without an argument +.Dq Fl x , +and with an argument +.Dq Fl x Ns Ar arg\^ . +In the latter case the argument must be part of the same +.Fa argv +word. +The +.Dq Fl x +and +.Dq Ar arg\^ +must not be separated by a whitespace on the command line. .Pp On return from .Fn getopt , @@ -267,7 +286,7 @@ Care should be taken not to use as the first character in .Fa optstring to avoid a semantic conflict with -.Tn GNU +GNU .Fn getopt , which assigns different meaning to an .Fa optstring