diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-26 22:21:03 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-26 22:22:01 +0200 |
commit | 5d8522cf2e5c661fb9250fb261e36b00de5dbe42 (patch) | |
tree | dd6ebce83f6f2b1301add8f510c6b46c268d4315 /bin/savepatch | |
parent | 09c0720ee7f4d949f3f779bb26ccb60faad56cd5 (diff) | |
download | patches-5d8522cf2e5c661fb9250fb261e36b00de5dbe42.tar.gz |
Add whereispatch script
Diffstat (limited to 'bin/savepatch')
-rwxr-xr-x | bin/savepatch | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/bin/savepatch b/bin/savepatch index f4c2bd6..2a6cec9 100755 --- a/bin/savepatch +++ b/bin/savepatch @@ -1,29 +1,17 @@ #!/bin/sh -# savepatch -- save patch on standard in to ~/patches - -root=/home/john/patches +# savepatch -- save patch on standard in if [ -z "$1" ]; then echo "usage: ${0##*/} patch-name" 1>&2 exit 1 fi -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 - printf "package: " 1>&2 - read dir </dev/tty -fi +dir=$(whereispatch -i) -mkdir -p "$root/$dir" +mkdir -p "$dir" -if [ -e "$root/$dir/$1" ]; then +if [ -e "$dir/$1" ]; then printf "%s: %s already exists; overwrite? " "${0##*/}" "$dir/$1" 1>&2 read ans </dev/tty case $ans in @@ -32,5 +20,5 @@ if [ -e "$root/$dir/$1" ]; then esac fi -cat > "$root/$dir/$1" -echo "$root/$dir/$1" +cat > "$dir/$1" +echo "$dir/$1" |