aboutsummaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rwxr-xr-xunix/makepatch.sh61
-rwxr-xr-xunix/snow.sh24
2 files changed, 85 insertions, 0 deletions
diff --git a/unix/makepatch.sh b/unix/makepatch.sh
new file mode 100755
index 0000000..86804ab
--- /dev/null
+++ b/unix/makepatch.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Automatically make the patches for the updated files by find
+# the corresponding '*.orig' files through the given directory.
+#
+# Based on the 'makepatch' target of FreeBSD 'Mk/bsd.port.mk'.
+#
+#
+# Aaron LI
+# Created: 2015-10-13
+# Updated: 2015-12-07
+#
+# ChangeLog:
+# 2015-12-06:
+# * Drop option '-s' for `find`
+# 2015-12-07:
+# * Replace 'workdir' with 'srcdir'
+# * Make find to search 'srcdir' instead of '.'
+#
+
+case "$1" in
+ -[hH]*|--[hH]*)
+ echo "Usage: $0 [srcdir] [patchdir]"
+ echo ""
+ echo "Both 'srcdir' and 'patchdir' default to be ."
+ exit 1
+ ;;
+esac
+
+SRCDIR=${1:-.}
+PATCHDIR=${2:-.}
+
+if [ ! -d "${PATCHDIR}" ]; then
+ mkdir ${PATCHDIR}
+fi
+
+PATCH_PATH_SEPARATOR="_"
+
+for f in `find ${SRCDIR}/ -type f -name '*.orig'`; do
+ _SEEN="NO"
+ ORIG=${f#./}
+ NEW=${ORIG%.orig}
+ if cmp -s ${ORIG} ${NEW}; then
+ # The two files are identical
+ continue
+ fi
+ PATCH=`echo ${NEW} | sed -e \
+ "s|${PATCH_PATH_SEPARATOR}|&&|g" -e "s|/|${PATCH_PATH_SEPARATOR}|g"`
+ OUT="${PATCHDIR}/patch-${PATCH}"
+ if test -f "${OUT}"; then
+ echo WARNING: patch already exists: \"${OUT}\"
+ else
+ echo diff -udp ${ORIG} ${NEW} '>' ${OUT}
+ TZ=UTC diff -udp ${ORIG} ${NEW} | sed -e \
+ '/^---/s|\.[0-9]* +0000$| UTC|' -e \
+ '/^+++/s|\([[:blank:]][-0-9:.+]*\)*$||' > ${OUT}
+ fi
+done
+
+exit 0
+
diff --git a/unix/snow.sh b/unix/snow.sh
new file mode 100755
index 0000000..57657d2
--- /dev/null
+++ b/unix/snow.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# Command line – Let it snow, Let it snow, Let it snow
+# http://mebsd.com/coding-snipits/command-line-let-it-snow-let-it-snow-let-it-snow.html
+# October 9, 2012
+#
+
+LINES=${LINES:-24}
+COLUMNS=${COLUMNS:-90}
+
+clear; \
+while :; \
+do \
+echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)); \
+sleep 0.1; \
+done | \
+awk '{ \
+ a[$3]=0; \
+ for(x in a) {o=a[x]; \
+ a[x]=a[x]+1; \
+ printf "\033[%s;%sH ",o,x; \
+ printf "\033[%s;%sH*\033[0;0H",a[x],x; \
+ } \
+ }'