annotate bin/roll @ 12220:7eaf71f23fbe draft

<oerjan> learn \xce\xbe\xcf\x80\xce\xb1\xce\xbb\xce\xb1\xce\xb9\xce\xbf\xce\xbb\xcf\x8c\xce\xb3\xce\xbf\xcf\x82 is kspalaiologos\'s Ancient Greek twin. He was banned from the theater for making up invalid characters.
author HackEso <hackeso@esolangs.org>
date Sun, 01 Dec 2019 02:35:07 +0000
parents e037173e0012
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
1 #!/bin/bash
e037173e0012 Initial import.
HackBot
parents:
diff changeset
2 rolls="$*"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
3 if [ "$rolls" = "" ] ; then rolls="1d6" ; fi
e037173e0012 Initial import.
HackBot
parents:
diff changeset
4
e037173e0012 Initial import.
HackBot
parents:
diff changeset
5 for i in $rolls
e037173e0012 Initial import.
HackBot
parents:
diff changeset
6 do
e037173e0012 Initial import.
HackBot
parents:
diff changeset
7 if expr "$i" : ".*[dD].*" >& /dev/null
e037173e0012 Initial import.
HackBot
parents:
diff changeset
8 then
e037173e0012 Initial import.
HackBot
parents:
diff changeset
9 rollc=`echo "$i" | sed 's/[dD].*//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
10 diesz=`echo "$i" | sed 's/.*[dD]//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
11 else
e037173e0012 Initial import.
HackBot
parents:
diff changeset
12 rollc=1
e037173e0012 Initial import.
HackBot
parents:
diff changeset
13 diesz="$i"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
14 fi
e037173e0012 Initial import.
HackBot
parents:
diff changeset
15
e037173e0012 Initial import.
HackBot
parents:
diff changeset
16 roll=0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
17 for (( j = 0; $j < $rollc; j++ ))
e037173e0012 Initial import.
HackBot
parents:
diff changeset
18 do
e037173e0012 Initial import.
HackBot
parents:
diff changeset
19 roll=$(( roll + (RANDOM % diesz) + 1 ))
e037173e0012 Initial import.
HackBot
parents:
diff changeset
20 done
e037173e0012 Initial import.
HackBot
parents:
diff changeset
21
e037173e0012 Initial import.
HackBot
parents:
diff changeset
22 echo -n $roll' '
e037173e0012 Initial import.
HackBot
parents:
diff changeset
23 done
e037173e0012 Initial import.
HackBot
parents:
diff changeset
24 echo