Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Apr 2026 03:50:01 +0000
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0985637687de - stable/14 - jls: minor simplification to arg handling
Message-ID:  <69e996e9.3b53c.711c73f5@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=0985637687dea7edcb58f76c065271a5036927a9

commit 0985637687dea7edcb58f76c065271a5036927a9
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-07-26 03:13:41 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-04-23 03:27:35 +0000

    jls: minor simplification to arg handling
    
    It's easier to reason about the state of argc/argv if we just augment
    them by optind after our getopt() loop.
    
    No functional change, but this sets the stage for another change to add
    a `-c` mode to (c)heck for the existence of a jail quietly without
    the caller having to worry about spurious output.
    
    Reviewed by:    jamie
    
    (cherry picked from commit dbaaadd4373a725950ad11e578dab61537b7c4f2)
---
 usr.sbin/jls/jls.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index f30b846a435d..6f8b214e8b9a 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -141,8 +141,11 @@ main(int argc, char **argv)
 	ip4_ok = feature_present("inet");
 #endif
 
+	argc -= optind;
+	argv += optind;
+
 	/* Add the parameters to print. */
-	if (optind == argc) {
+	if (argc == 0) {
 		if (pflags & (PRINT_HEADER | PRINT_NAMEVAL))
 			add_param("all", NULL, (size_t)0, NULL, JP_USER);
 		else if (pflags & PRINT_VERBOSE) {
@@ -180,9 +183,8 @@ main(int argc, char **argv)
 		}
 	} else {
 		pflags &= ~PRINT_VERBOSE;
-		while (optind < argc)
-			add_param(argv[optind++], NULL, (size_t)0, NULL,
-			    JP_USER);
+		for (i = 0; i < argc; i++)
+			add_param(argv[i], NULL, (size_t)0, NULL, JP_USER);
 	}
 
 	if (pflags & PRINT_SKIP) {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e996e9.3b53c.711c73f5>