summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2017-02-11 02:13:43 (EST)
committer P. J. McDermott <pj@pehjota.net>2017-02-11 02:13:43 (EST)
commit215d095f88c0cdc3fd65ae7e3f5c8d87a535481c (patch)
tree05d6d9b8feaa1044a7b48ff1a49827c36e84cdd7
parentea45d18dbcf3dde557666ddc830b3a42bcb10286 (diff)
downloadeggshell-215d095f88c0cdc3fd65ae7e3f5c8d87a535481c.zip
eggshell-215d095f88c0cdc3fd65ae7e3f5c8d87a535481c.tar.gz
eggshell-215d095f88c0cdc3fd65ae7e3f5c8d87a535481c.tar.bz2
research/split.sh: New file
-rw-r--r--research/split.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/research/split.sh b/research/split.sh
new file mode 100644
index 0000000..9a3aed3
--- /dev/null
+++ b/research/split.sh
@@ -0,0 +1,18 @@
+US="$(printf '\037.')"; US="${US%.}"
+
+buf='Hello, world!'
+
+printf '%s' "${buf}" | sed "s/\\(.\\)/\\1${US}/g" | \
+ awk -v FS="${US}" -v j=0 -v squote="'" -v esc_squote="'\\\\''" '
+ {
+ for (i = 1; i <= NF; ++i) {
+ if ($i == "") {
+ continue;
+ }
+ sub(squote, esc_squote, $i);
+ printf("lbufv_%d=" squote "%s" squote "\n",
+ j++, $i);
+ };
+ printf("lbufv_%d=" squote "\n" squote "\n", j++);
+ }
+ '