aboutsummaryrefslogtreecommitdiff
path: root/bin/whereispatch
blob: 1eea64ad60a82d0d47dd9aaea97b80a7025bf6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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"