git: 0619dbdfde6d - stable/13 - ldconfig(8): check for no-args command line after options are parsed

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 01 Dec 2021 01:08:26 UTC
The branch stable/13 has been updated by kib:

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

commit 0619dbdfde6d05ac99265ff0b0944468788678dd
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-19 04:07:58 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-12-01 01:07:19 +0000

    ldconfig(8): check for no-args command line after options are parsed
    
    (cherry picked from commit 3ede04c78c7c726ed79a39d22c65a58d0ecc5d00)
---
 sbin/ldconfig/ldconfig.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c
index 288c22813121..b039412a648b 100644
--- a/sbin/ldconfig/ldconfig.c
+++ b/sbin/ldconfig/ldconfig.c
@@ -90,9 +90,7 @@ main(int argc, char **argv)
 		hints_file = _PATH_ELF32_HINTS;
 	else
 		hints_file = _PATH_ELF_HINTS;
-	if (argc == 1)
-		rescan = true;
-	else while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
+	while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
 		switch (c) {
 		case 'R':
 			rescan = true;
@@ -121,11 +119,14 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (justread)
+	if (justread) {
 		list_elf_hints(hints_file);
-	else
+	} else {
+		if (argc == optind)
+			rescan = true;
 		update_elf_hints(hints_file, argc - optind,
 		    argv + optind, merge || rescan);
+	}
 	exit(0);
 }