Created
November 16, 2017 13:47
-
-
Save Bombe/b7cff7918338a5056c1ce4957d8d7cc5 to your computer and use it in GitHub Desktop.
Makes a decision between a number of given options.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 64D16CF7-35CB-4E1D-83E4-504260998EC4 | |
numberOfChoices="${#@}" | |
if [ "${numberOfChoices}" == "0" ]; then | |
r="$((${RANDOM} % 2))" | |
if [ "${r}" == "0" ]; then | |
echo "No." | |
else | |
echo "Yes." | |
fi | |
elif [ "${numberOfChoices}" == "1" ]; then | |
r="$((${RANDOM} % 2))" | |
if [ "${r}" == "0" ]; then | |
echo "I would not choose ${1}." | |
else | |
echo "I would choose ${1}." | |
fi | |
else | |
r="$((${RANDOM} % ${numberOfChoices}))" | |
echo "I would choose ${@:$(($r+1)):1}." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment