diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-27 01:00:12 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-27 01:00:12 +0200 |
commit | c842c23a067977a1ec9edb28e1feb062c1b08a41 (patch) | |
tree | d1a1b39a23a2effb559ff9c407e8eefb5cd61b8b /bin | |
parent | 4e5607ca59a45fe54da4d3d4c8f5e8c9df240c4c (diff) | |
download | patches-c842c23a067977a1ec9edb28e1feb062c1b08a41.tar.gz |
savepatch: Wait for text on stdin before asking for confirmation
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/savepatch | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/savepatch b/bin/savepatch index 2a6cec9..963fbab 100755 --- a/bin/savepatch +++ b/bin/savepatch @@ -11,8 +11,10 @@ dir=$(whereispatch -i) mkdir -p "$dir" +read -r first if [ -e "$dir/$1" ]; then - printf "%s: %s already exists; overwrite? " "${0##*/}" "$dir/$1" 1>&2 + printf "%s: %s already exists; overwrite? " \ + "${0##*/}" "${dir#/home/*/patches/}/$1" 1>&2 read ans </dev/tty case $ans in y*) ;; @@ -20,5 +22,5 @@ if [ -e "$dir/$1" ]; then esac fi -cat > "$dir/$1" +{ echo "$first"; cat; } > "$dir/$1" echo "$dir/$1" |