diff options
author | Kerin Millar <kfm@plushkava.net> | 2024-06-27 18:24:03 +0100 |
---|---|---|
committer | Kerin Millar <kfm@plushkava.net> | 2024-06-28 18:39:01 +0100 |
commit | 7dec95c33a711a01f90993ee08a06de6df1a0806 (patch) | |
tree | 99678472fdfcb7226b2345d713758c5db9d357ee | |
parent | Align the indentation of inlined awk programs with their respective heredocs (diff) | |
download | gentoo-functions-7dec95c33a711a01f90993ee08a06de6df1a0806.tar.gz gentoo-functions-7dec95c33a711a01f90993ee08a06de6df1a0806.tar.bz2 gentoo-functions-7dec95c33a711a01f90993ee08a06de6df1a0806.zip |
Implement array membership tests idiomatically in quote_args()
Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r-- | functions.sh | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/functions.sh b/functions.sh index 3dd6239..367c4a3 100644 --- a/functions.sh +++ b/functions.sh @@ -377,7 +377,7 @@ quote_args() word = q arg q } else { # Use $'' quoting per Issue 8 - if (ord_by["\001"] == "") { + if (! ("\001" in ord_by)) { for (i = 1; i < 32; i++) { char = sprintf("%c", i) ord_by[char] = i @@ -391,13 +391,10 @@ quote_args() word = word "\\\\" } else if (char == q) { word = word "\\'" + } else if (char in ord_by) { + word = word "\\" sprintf("%03o", ord_by[char]) } else { - ord = ord_by[char] - if (ord != "") { - word = word "\\" sprintf("%03o", ord) - } else { - word = word char - } + word = word char } } word = word q |