Skip to content

Commit b090605

Browse files
Add files via upload
1 parent 08b76be commit b090605

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

521a.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#! /bin/bash
2+
# calculate-- kind of bc-alike tool
3+
4+
scale=2
5+
6+
show_help()
7+
{
8+
9+
#(a)
10+
cat << EOF
11+
12+
a % b =餘數
13+
a ^ b =a 的 b 次方
14+
l(x)x =10 的 x 次方
15+
e(x) = e 的 x 次方
16+
scale N =小數取兩位(預設為 2)
17+
EOF
18+
19+
}
20+
21+
22+
if [ $# -gt 0 ]; then
23+
24+
exec scriptbc "$@" #(b)
25+
26+
fi
27+
28+
echo "calculate-- help or quit?"
29+
30+
/bin/echo -n "calculate> " #(c) /bin/echo -n ""
31+
32+
33+
while read cmd args # param is called cmd and args # (d) while read loop
34+
do
35+
36+
case $cmd
37+
in
38+
39+
quit | exit ) exit ;;
40+
help | ? ) show_help ;;
41+
scale ) scale=$args ;;
42+
* ) scriptbc -p $scale "$cmd" "$args" ;; (c)
43+
44+
esac
45+
46+
/bin/echo -n "calculate> "
47+
48+
done
49+
50+
51+
echo " "
52+
53+
exit 0
54+

0 commit comments

Comments
 (0)