Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions python2/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
#!/bin/sh

if [ -x /usr/bin/python2 ]; then
python2 -B contemplate_koans.py
BIN=python2
else
python -B contemplate_koans.py
BIN=python
fi

function contemplate(){
$BIN -B contemplate_koans.py
}

if [ -z $2 ]; then
SLEEP_S=5
else
SLEEP_S=$2
fi

while true; do
contemplate

case $1 in
help|h)
clear
echo "This script will contemplate the phython koans"
echo "usage: `basename $0` (mode)"
echo
echo "Optional modes:"
echo "\tkeeptesting (seconds)\t - Contemplate forever with a configurable delay"
echo "\tkeepasking \t\t - Asks you to contemplate over and over until you had enough"
echo
exit
;;
keepasking)
if [ "$1" == "keepasking" ]; then
read -p "Keep testing? [y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]];then
break
fi
fi
;;
keeptesting)
sleep $SLEEP_S
continue
;;
*)
exit
;;
esac
done

44 changes: 43 additions & 1 deletion python3/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
#!/bin/sh

python3 -B contemplate_koans.py
function contemplate(){
python3 -B contemplate_koans.py
}

if [ -z $2 ]; then
SLEEP_S=5
else
SLEEP_S=$2
fi

while true; do
contemplate

case $1 in
help|h)
clear
echo "This script will contemplate the phython koans"
echo "usage: `basename $0` (mode)"
echo
echo "Optional modes:"
echo "\tkeeptesting (seconds)\t - Contemplate forever with a configurable delay"
echo "\tkeepasking \t\t - Asks you to contemplate over and over until you had enough"
echo
exit
;;
keepasking)
if [ "$1" == "keepasking" ]; then
read -p "Keep testing? [y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]];then
break
fi
fi
;;
keeptesting)
sleep $SLEEP_S
continue
;;
*)
exit
;;
esac
done