From: Ruediger Meier Date: Mon, 7 Mar 2016 10:44:55 +0000 (+0100) Subject: getopt: fix -n name for BSD X-Git-Tag: v2.28-rc1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c78d493c05d03b119f1d1c76874ac31f909655a;p=thirdparty%2Futil-linux.git getopt: fix -n name for BSD BSD gets the program name for warnings from getprogname() and not from argv. Thus we use setprogname() there. Signed-off-by: Ruediger Meier --- diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c index c166fd756e..c4144f63e4 100644 --- a/misc-utils/getopt.c +++ b/misc-utils/getopt.c @@ -62,6 +62,9 @@ #include #include #include +#ifdef HAVE_SYS_PARAM_H +# include /* 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);