1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-06-29 02:17:12 -07:00
rc/sh/confirm

19 lines
391 B
Plaintext
Raw Normal View History

2013-06-28 05:22:14 -07:00
#!/usr/bin/env bash
if [ -n "${ZSH_VERSION:-}" ]; then
2013-07-01 18:05:17 -07:00
confirm() {
read -q '?Continue? [Y/n] '
ret=$?
echo
return $ret
}
2013-06-28 05:22:14 -07:00
else
2013-07-01 18:05:17 -07:00
confirm() {
# specify stdin (1) to avoid taking input from pipes
read -n1 -u 1 -p "Continue? [Y/n] " c
echo
[ "$c" != 'y' ] && [ "$c" != 'Y' ] && return 1
return 0
}
2013-06-28 05:22:14 -07:00
fi
confirm