aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-27 17:54:52 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-27 17:54:52 +0200
commitc1f551e00db12429b9df006ec200a56845d0f753 (patch)
tree30eabde3f496da982e88100acaff0e01257ce148
parentba8a3ef6524e9dc6267a036ee33a9fcd01571d13 (diff)
downloadpatches-c1f551e00db12429b9df006ec200a56845d0f753.tar.gz
whereispatch: Ensure patch path does not contain newlines
-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