blob: c0f9ce50f41a6295521337c1d0fcee0afd32cbf7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env sh
helpmsg() {
printf "%s\n" "desc: commandline calculator (ctrl+d to exit)"
printf "%s\n" "demo: http://www.youtube.com/watch?v=JkyodHenTuc"
printf "%s\n" "depends: python2, python3 or bc"
printf "\n"
printf "%s\n" "usage: ${0##*/}"
}
if [ "$1" = -h ] || [ "$1" = --help ]; then
helpmsg
exit 0
elif command -v python3 >/dev/null; then
python3 -ic "from math import *; import cmath"
elif command -v python2 >/dev/null; then
python2 -ic "from __future__ import division; from math import *; from random import *"
elif command -v bc >/dev/null; then
bc -q -l
else
printf "%s\n" "missing python2, python3 or bc"
exit 1
fi
|