[PATCH 12/12] getopt: fix -n name for BSD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>

BSD gets the program name for warnings from getprogname() and not
from argv. Thus we use setprogname() there.

Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
---
 misc-utils/getopt.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c
index c166fd7..c4144f6 100644
--- a/misc-utils/getopt.c
+++ b/misc-utils/getopt.c
@@ -62,6 +62,9 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <getopt.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h> /* BSD */
+#endif
 
 #include "closestream.h"
 #include "nls.h"
@@ -447,9 +450,13 @@ int main(int argc, char *argv[])
 			optind++;
 		}
 	}
-	if (name)
+
+	if (name) {
 		argv[optind - 1] = name;
-	else
+#if defined (BSD) || defined (__APPLE__)
+		setprogname(name);
+#endif
+	} else
 		argv[optind - 1] = argv[0];
 
 	return generate_output(&ctl, argv + optind - 1, argc - optind + 1);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux