aboutsummaryrefslogtreecommitdiff
path: root/bin/savepatch
blob: 2a6cec9ec2e50d5287b40e1e7c9222fc56cd9cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# savepatch -- save patch on standard in

if [ -z "$1" ]; then
	echo "usage: ${0##*/} patch-name" 1>&2
	exit 1
fi

dir=$(whereispatch -i)

mkdir -p "$dir"

if [ -e "$dir/$1" ]; then
	printf "%s: %s already exists; overwrite? " "${0##*/}" "$dir/$1" 1>&2
	read ans </dev/tty
	case $ans in
	y*) ;;
	*) exit 1 ;;
	esac
fi

cat > "$dir/$1"
echo "$dir/$1"