1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-14 17:19:02 -08:00
rc/sh/confirm

19 lines
391 B
Text
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