21 lines
586 B
Bash
21 lines
586 B
Bash
#!/usr/bin/env bash
|
|
|
|
# matches any character that is not in the set of letters, digits, and question marks.
|
|
cleaned="${1//[^a-zA-Z0-9\?]}"
|
|
|
|
# all capitals and ending with ?
|
|
if [[ "$cleaned" =~ ^[A-Z]+\?$ ]] ; then
|
|
echo "Calm down, I know what I'm doing!"
|
|
# ending with ?
|
|
elif [[ "$cleaned" =~ ^.*[a-z0-9]*.*\?$ ]] ; then
|
|
echo 'Sure.'
|
|
# all capitals and not only digits
|
|
elif [[ "$cleaned" =~ ^[A-Z0-9]+$ ]] && ! [[ "$cleaned" =~ ^[0-9]+$ ]] ; then
|
|
echo 'Whoa, chill out!'
|
|
# if empty
|
|
elif [[ -z "$cleaned" ]] ; then
|
|
echo 'Fine. Be that way!'
|
|
else
|
|
echo 'Whatever.'
|
|
fi
|