]> git.draconx.ca Git - dxcommon.git/blobdiff - scripts/gen-options.awk
gen-options.awk: Work around busybox regex bug.
[dxcommon.git] / scripts / gen-options.awk
index 679dc9904c4770fbcbec5f6d32dc991a42237ef4..a93c47cf95e576d5a723c6101d7d315a13461f49 100755 (executable)
@@ -152,7 +152,7 @@ $0 ~ /^-/ {
   }
 
   # Extract argument name
-  if (work ~ /^\[=[^\] \t]+\]/) {
+  if (work ~ /^\[=[^ \t]+\]/ && sub(/\]/, "&", work) == 1) {
     if (n = index(work, "]")) {
       arg = substr(work, 3, n-3)
       work = substr(work, n+1)
@@ -213,7 +213,9 @@ lopt {
   sub(/^[ \t]*/, "")
   if (!$0) { next }
 
-  optionhelp[lopt] = (lopt in optionhelp ? optionhelp[lopt] "\n" : "") $0
+  if (lopt in optionhelp)
+    $0 = "\n" $0;
+  optionhelp[lopt] = optionhelp[lopt] $0;
 }
 
 # Exit immediately on error