The branch main has been updated by kevans:

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

commit dbaaadd4373a725950ad11e578dab61537b7c4f2
Author:     Kyle Evans <kev...@freebsd.org>
AuthorDate: 2025-07-26 03:13:41 +0000
Commit:     Kyle Evans <kev...@freebsd.org>
CommitDate: 2025-07-26 03:13:41 +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
    Differential Revision:  https://reviews.freebsd.org/D51540
---
 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 bd193a69c458..a1d1716713aa 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -140,8 +140,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) {
@@ -179,9 +182,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) {

Reply via email to