aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/whereispatch16
1 files changed, 14 insertions, 2 deletions
diff --git a/bin/whereispatch b/bin/whereispatch
index 1eea64a..0300663 100755
--- a/bin/whereispatch
+++ b/bin/whereispatch
@@ -2,7 +2,9 @@
# whereispatch -- print corresponding patch directory
-root=/home/john/patches
+IFS='
+'
+: ${PATCHROOT:=/home/$USER/patches}
case "$PWD" in
/usr/pkgsrc/*) dir=$(pwd | cut -d/ -f4,5) || dir= ;;
@@ -17,4 +19,14 @@ if [ -z "$dir" ]; then
read dir </dev/tty
fi
-echo "$root/$dir"
+dir=${dir%/*.pkgwcp}
+dir=$PATCHROOT/$dir
+
+n=0
+for parts in $dir; do : $((n++)); done
+if [ $n -gt 1 ]; then
+ echo "${0##*/}: newlines in patch path" 1>&2
+ exit 1
+fi
+
+echo $dir