diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-10-01 21:41:24 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-10-01 21:41:24 +0300 |
commit | 63cf4c66e97a92f3e553707ecd0bc278a7cc4563 (patch) | |
tree | a885bea63fd2e8636d2dd7d7e7a1b3ea646b0c8f /awklib/eg/lib/shellquote.awk | |
parent | 63c4c29e1ebfb0e68fe622bea1c4ed82ac6a6a02 (diff) | |
download | egawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.tar.gz egawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.tar.bz2 egawk-63cf4c66e97a92f3e553707ecd0bc278a7cc4563.zip |
More doc updates.
Diffstat (limited to 'awklib/eg/lib/shellquote.awk')
-rw-r--r-- | awklib/eg/lib/shellquote.awk | 22 |
1 files changed, 22 insertions, 0 deletions
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 +} |