some script I wrote for a quick hack
authormirabilos <m@mirbsd.org>
Sat, 4 Jun 2016 03:19:59 +0000 (03:19 +0000)
committermirabilos <m@mirbsd.org>
Sat, 4 Jun 2016 03:19:59 +0000 (03:19 +0000)
mksh/mergelines [new file with mode: 0644]

diff --git a/mksh/mergelines b/mksh/mergelines
new file mode 100644 (file)
index 0000000..30ef39b
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/mksh
+# $MirOS: src/share/misc/licence.template,v 1.28 2008/11/14 15:33:44 tg Rel $
+#-
+# Copyright © 2016
+#      mirabilos <m@mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+
+[[ -n $1 ]] && IFS=$1
+
+l1=
+l2=
+lp=0
+while read -r n1 n2; do
+       if [[ $n1 = $l1 ]]; then
+               l2+=$IFS$n2
+               lp=1
+               continue
+       fi
+       if (( lp )); then
+               print -r -- "$l1$IFS$l2"
+               lp=0
+       fi
+       l1=$n1
+       l2=$n2
+done
+(( lp )) && print -r -- "$l1$IFS$l2"