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() {
2015-05-23 01:16:56 -07:00
read -q '?Continue? [y/N] '
2013-07-01 18:05:17 -07:00
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
2015-05-23 01:16:56 -07:00
read -n1 -u 1 -p "Continue? [y/N] " c
2013-07-01 18:05:17 -07:00
echo
[ "$c" != 'y' ] && [ "$c" != 'Y' ] && return 1
return 0
}
2013-06-28 05:22:14 -07:00
fi
confirm