-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfizzbuzz.sh6
executable file
·45 lines (36 loc) · 1.35 KB
/
fizzbuzz.sh6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env osh
: "Language: Thompson Shell (Unix V6)"
: "Web site: https://etsh.nl/"
: "Last tested on: Ubuntu 24.04.2 LTS"
: "Requires: Install from source, https://etsh.nl/src/osh-4.2.1.tar.gz"
: " NOTE: Using the sh6 command, this works under Linux"
: " Mint 17.3, but fails under Ubuntu 17.10, apparently due"
: " to a problem with the external goto command Attempts"
: " to diagnose and correct the problem, with the help of"
: " J.A. Neitzel, the maintainer of the v6shell project,"
: " were unsuccessful. As a workaround, I'm now using osh"
: " (which implements goto internally) rather than sh6."
echo 0 > _count
: LOOP
( cat _count ; echo 1 + p ) | dc > _count.new ; mv _count.new _count
( cat _count ; echo 15 % p ) | dc > _imod15
if { grep -v '^0$' _imod15 > /dev/null } goto L1
echo FizzBuzz
goto NEXT
: L1
( cat _count ; echo 3 % p ) | dc > _imod3
if { grep -v '^0$' _imod3 > /dev/null } goto L2
echo Fizz
goto NEXT
: L2
( cat _count ; echo 5 % p ) | dc > _imod5
if { grep -v '^0$' _imod5 > /dev/null } goto L3
echo Buzz
goto NEXT
: L3
cat _count
: NEXT
if { grep '^100$' _count > /dev/null } goto DONE
goto LOOP
: DONE
rm _count _imod3 _imod5 _imod15