summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-09-13 02:37:40 +0200
committerJustin Davis <jrcd83@gmail.com>2011-09-13 02:37:40 +0200
commit00bc1b4d6e10932608e971047effa208e330e325 (patch)
treec13a034a79f6dcbe6e4a3082d30c20af9065f294 /bin
parent4f94b12490329c9cb1fe9a824989ef566b8df712 (diff)
downloadgenpkg-00bc1b4d6e10932608e971047effa208e330e325.tar.gz
genpkg-00bc1b4d6e10932608e971047effa208e330e325.tar.xz
New addln script adds lines to PKGBUILD funcs. Fix perlbrew's license.
The LICENSE file had to be copied to the standard location. This required the new addln script to be created.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/addln21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/addln b/bin/addln
new file mode 100755
index 0000000..6a39dbd
--- /dev/null
+++ b/bin/addln
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $# -lt 1 ] ; then
+ cat 1>&2 <<EOF
+Usage: addln [PKGBUILD function] [line of bash]
+
+Reads the PKGBUILD from standard input, adding a line at the end of the
+specified bash function. The line can be empty to just add a newline.
+EOF
+ exit 1
+fi
+
+fname=$1
+shift
+
+awk -v fname="$fname" -v line="$*" '
+match($0, "^[ \\t]*" fname "\\(\\)") { active = 1 }
+active && match($0, /^[ ]+/) { indent = substr($0, 1, RLENGTH) }
+active && /^}/ { active = 0; print indent "" line }
+1
+'