From 275b1bc0f36f26e0816413903f899a1d7c1aad0e Mon Sep 17 00:00:00 2001 From: Koichi Nakashima Date: Mon, 19 Aug 2024 23:33:44 +0900 Subject: [PATCH] exporter: Cleanup getopts --- src/exporter.awk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/exporter.awk b/src/exporter.awk index d783812..78c079d 100644 --- a/src/exporter.awk +++ b/src/exporter.awk @@ -3,22 +3,25 @@ function getopts(optstring, args, opt, oarg, i, j) { j = int(substr(OPTIND, length(i) + 2)) if (! (i in args)) return "" if (args[i] == "--") { OPTIND = i + 1; return "" } - if (args[i] !~ /^-./) { return "" } + if (args[i] !~ /^-./) return "" opt = substr(args[i], j + 2, 1) oarg = substr(args[i], j + 3) if (index(optstring, opt ":")) { if (oarg == "") { if ( (i + 1) in args ) { - OPTARG = args[i + 1]; OPTIND = i + 2 + OPTARG = args[i + 1] + OPTIND = i + 2 } else { OPTARG = "option requires an argument -- " opt opt = "?" } } else { - OPTARG = oarg; OPTIND = i + 1 + OPTARG = oarg + OPTIND = i + 1 } } else if (index(optstring, opt)) { - OPTARG = ""; OPTIND = (oarg == "") ? (i + 1) : (i "," (j + 1)) + OPTARG = "" + OPTIND = (oarg == "") ? (i + 1) : (i "," (j + 1)) } else { OPTARG = "illegal option -- " opt opt = "?"