aboutsummaryrefslogtreecommitdiffstats
path: root/awklib
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-10-01 21:41:24 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-10-01 21:41:24 +0300
commit63cf4c66e97a92f3e553707ecd0bc278a7cc4563 (patch)
treea885bea63fd2e8636d2dd7d7e7a1b3ea646b0c8f /awklib
parent63c4c29e1ebfb0e68fe622bea1c4ed82ac6a6a02 (diff)
downloadegawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.tar.gz
egawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.tar.bz2
egawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.zip
More doc updates.
Diffstat (limited to 'awklib')
-rw-r--r--awklib/eg/lib/processarray.awk12
-rw-r--r--awklib/eg/lib/shellquote.awk22
2 files changed, 34 insertions, 0 deletions
diff --git a/awklib/eg/lib/processarray.awk b/awklib/eg/lib/processarray.awk
new file mode 100644
index 00000000..79a86d1f
--- /dev/null
+++ b/awklib/eg/lib/processarray.awk
@@ -0,0 +1,12 @@
+function process_array(arr, name, process, do_arrays, i, new_name)
+{
+ for (i in arr) {
+ new_name = (name "[" i "]")
+ if (isarray(arr[i])) {
+ if (do_arrays)
+ @process(new_name, arr[i])
+ process_array(arr[i], new_name, process, do_arrays)
+ } else
+ @process(new_name, arr[i])
+ }
+}
diff --git a/awklib/eg/lib/shellquote.awk b/awklib/eg/lib/shellquote.awk
new file mode 100644
index 00000000..cd943dc7
--- /dev/null
+++ b/awklib/eg/lib/shellquote.awk
@@ -0,0 +1,22 @@
+# shell_quote --- quote an argument for passing to the shell
+#
+# Michael Brennan
+# brennan@madronabluff.com
+# September 2014
+
+function shell_quote(s, # parameter
+ SINGLE, QSINGLE, i, X, n, ret) # locals
+{
+ if (s == "")
+ return "\"\""
+
+ SINGLE = "\x27" # single quote
+ QSINGLE = "\"\x27\""
+ n = split(s, X, SINGLE)
+
+ ret = SINGLE X[1] SINGLE
+ for (i = 2; i <= n; i++)
+ ret = ret QSINGLE SINGLE X[i] SINGLE
+
+ return ret
+}