diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2025-07-26 03:13:41 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2025-07-26 03:13:41 +0000 |
| commit | dbaaadd4373a725950ad11e578dab61537b7c4f2 (patch) | |
| tree | dc36eab447c66927b99ca085414c09bcace4a08e | |
| parent | cfc595f4a05ed6fc690b17adee967e652b8636b3 (diff) | |
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
| -rw-r--r-- | usr.sbin/jls/jls.c | 10 |
1 files 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) { |
