From d322136c3dde30799a22a1c07b6f6091614b745c Mon Sep 17 00:00:00 2001 From: millert Date: Wed, 20 Sep 2023 16:57:12 +0000 Subject: [PATCH] Support --version option like upstream awk but don't document it. Upstream awk has supported --version for a long time but does not support -V like our awk does. Both options are supported by gawk. --- usr.bin/awk/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c index 5a976d82814..2ec0bc7d9e9 100644 --- a/usr.bin/awk/main.c +++ b/usr.bin/awk/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.61 2023/09/18 19:32:19 millert Exp $ */ +/* $OpenBSD: main.c,v 1.62 2023/09/20 16:57:12 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -170,6 +170,10 @@ int main(int argc, char *argv[]) yyin = NULL; symtab = makesymtab(NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { + if (strcmp(argv[1], "--version") == 0) { + printf("awk %s\n", version); + return 0; + } if (strcmp(argv[1], "--") == 0) { /* explicit end of args */ argc--; argv++; @@ -214,8 +218,7 @@ int main(int argc, char *argv[]) break; case 'V': /* added for exptools "standard" */ printf("awk %s\n", version); - exit(0); - break; + return 0; default: WARNING("unknown option %s ignored", argv[1]); break; -- 2.20.1