From da190f713cdc93dda6a24fafe0acc5e599706433 Mon Sep 17 00:00:00 2001 From: DTB Date: Sat, 10 Aug 2024 22:18:15 -0600 Subject: [PATCH] npc(1): tweak OpenBSD functions --- src/npc.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/npc.c b/src/npc.c index 5b6c5c9..cd488e5 100644 --- a/src/npc.c +++ b/src/npc.c @@ -39,22 +39,20 @@ usage(char *argv0) { } int main(int argc, char *argv[]) { -#ifdef __OpenBSD__ - program_name = argv[0] == NULL ? program_name : argv[0]; - - if (pledge("stdio", NULL) == -1) { - perror(program_name); - return EX_OSERR; - } -#endif int c; char showend = 0; /* print a dollar sign before each newline */ char showtab = 0; /* prints tab characters in caret notation */ - if (argc > 0) { -#ifndef __OpenBSD__ - program_name = argv[0]; +#ifdef __OpenBSD__ + if (pledge("stdio", NULL) == -1) { + perror(argv[0] == NULL ? program_name : argv[0]); + return EX_OSERR; + } #endif + + if (argc > 0) { + program_name = argv[0]; + while ((c = getopt(argc, argv, "et")) != -1) { switch (c){ case 'e': showend = 1; break;