From 4f61ed84834fe717dc7a562d725d9e7234b51965 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 22 Jun 2021 18:32:24 +0000 Subject: [PATCH] Hoist initialization of _nc_progname to start of main() This way early calls to err(), failed() and usage() show "reset" instead of "tset" if the program was invoked as reset(1). Issue noted by jmc ok kn --- usr.bin/tset/tset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c index 021a44e6425..c6c2e84dfc0 100644 --- a/usr.bin/tset/tset.c +++ b/usr.bin/tset/tset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tset.c,v 1.41 2019/06/28 13:35:05 deraadt Exp $ */ +/* $OpenBSD: tset.c,v 1.42 2021/06/22 18:32:24 tb Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -110,7 +110,7 @@ extern char **environ; #undef CTRL #define CTRL(x) ((x) & 0x1f) -const char *_nc_progname = "tset"; +const char *_nc_progname; static TTY mode, oldmode, original; @@ -1136,6 +1136,8 @@ main(int argc, char **argv) const char *p; const char *ttype; + _nc_progname = _nc_rootname(*argv); + if (pledge("stdio rpath wpath tty", NULL) == -1) err("pledge: %s", strerror(errno)); @@ -1198,8 +1200,6 @@ main(int argc, char **argv) usage(); } } - - _nc_progname = _nc_rootname(*argv); argc -= optind; argv += optind; -- 2.20.1