aboutsummaryrefslogtreecommitdiff
path: root/bin/whereispatch
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-26 22:21:03 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-26 22:22:01 +0200
commit5d8522cf2e5c661fb9250fb261e36b00de5dbe42 (patch)
treedd6ebce83f6f2b1301add8f510c6b46c268d4315 /bin/whereispatch
parent09c0720ee7f4d949f3f779bb26ccb60faad56cd5 (diff)
downloadpatches-5d8522cf2e5c661fb9250fb261e36b00de5dbe42.tar.gz
Add whereispatch script
Diffstat (limited to 'bin/whereispatch')
-rwxr-xr-xbin/whereispatch20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/whereispatch b/bin/whereispatch
new file mode 100755
index 0000000..1eea64a
--- /dev/null
+++ b/bin/whereispatch
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# whereispatch -- print corresponding patch directory
+
+root=/home/john/patches
+
+case "$PWD" in
+/usr/pkgsrc/*) dir=$(pwd | cut -d/ -f4,5) || dir= ;;
+/usr/*src/*) dir=${PWD#/usr/} ;;
+*) dir=
+esac
+
+if [ -z "$dir" ]; then
+ echo "${0##*/}: could not determine package" 1>&2
+ [ x"$1" = x"-i" ] || exit 1
+ printf "package: " 1>&2
+ read dir </dev/tty
+fi
+
+echo "$root/$dir"