Skip to content

Instantly share code, notes, and snippets.

@jdaudier
Last active August 29, 2015 13:56
Show Gist options
  • Save jdaudier/9237946 to your computer and use it in GitHub Desktop.
Save jdaudier/9237946 to your computer and use it in GitHub Desktop.
File Russian Roulette: The most dangerous game ever!
#!/bin/bash
echo "Number of arguments: $#"
if [[ $# -ne 1 ]]
then
echo "We need a file to kill!"
exit 1
fi
if [[ -f $1 ]]
then
echo "File $1 loaded."
else
echo "$1 doesn't exist!"
exit 1
fi
echo "Welcome to the most dangerous game ever!"
echo "Loading bullet!"
BULLET=$((RANDOM%6+1))
echo "Spinning cylinder!"
CYLINDER=$((RANDOM%6+1))
BLAMS=0
while [[ $BLAMS -lt 1 ]] ; do
echo "Press any key to pull the trigger, or press CTRL + C to chicken out."
read -sn 1
if [[ $CYLINDER -eq $BULLET ]]; then
echo "Bullet is in chamber $BULLET."
echo "Cylinder is in position $CYLINDER."
echo "BLAM!"
echo "$1's bits were eradicated from existence."
BLAMS=$((BLAMS+1))
rm -rf $1
else
echo "Click. $1 lives to experience another cycle."
echo "Cylinder is in position $CYLINDER."
fi
CYLINDER=$(((CYLINDER%6)+1))
done
echo "Thanks for playing!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment