diff options
author | Case Duckworth | 2022-07-06 22:00:30 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-06 22:00:30 -0500 |
commit | 3c6ce827a002c54deb88e40cbddddb03866e695b (patch) | |
tree | f9286a57c2c6821b718efb682ddbca453411c17e /fucktrain | |
parent | Probably version ... whatever the next higher one is (diff) | |
download | trainfuck-3c6ce827a002c54deb88e40cbddddb03866e695b.tar.gz trainfuck-3c6ce827a002c54deb88e40cbddddb03866e695b.zip |
Big update
Diffstat (limited to 'fucktrain')
-rwxr-xr-x | fucktrain | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/fucktrain b/fucktrain index 7ade621..1c25aff 100755 --- a/fucktrain +++ b/fucktrain | |||
@@ -1,37 +1,30 @@ | |||
1 | #!/bin/awk -f | 1 | #!/bin/sh |
2 | # FUCKTRAIN: FUCKAMUTHA CHOO CHOO -*- awk -*- | 2 | # TRAINFUCK: CHOO CHOO MUTHAFUCKA -*- sh -*- |
3 | # Author: Case Duckworth <acdw@acdw.net> | 3 | # Author: Case Duckworth <acdw@acdw.net> |
4 | # License: WTFPL | 4 | # License: WTFPL |
5 | # Version: #9 | 5 | # Version: #9 |
6 | BEGIN { | ||
7 | print "ALL ABOARD" | ||
8 | } | ||
9 | 6 | ||
10 | { | 7 | ### Commentary: |
11 | gsub(/[^-+<>.,\[\]]/, "", $0) | ||
12 | gsub(/+/, "chug ", $0) | ||
13 | gsub(/-/, "chugga ", $0) | ||
14 | gsub(/>/, "choo\n", $0) | ||
15 | gsub(/</, "choo choo\n", $0) | ||
16 | gsub(/\./, clicketyClick(), $0) | ||
17 | gsub(/,/, "clack ", $0) | ||
18 | gsub(/\[/, "tickets please ", $0) | ||
19 | gsub(/\]/, "your ticket please ", $0) | ||
20 | if ($0) { | ||
21 | |||
22 | } | ||
23 | } | ||
24 | 8 | ||
25 | END { | 9 | # shell wrapper around fucktrain.awk, which see. |
26 | print "END OF THE LINE" | ||
27 | } | ||
28 | 10 | ||
11 | ### Code: | ||
29 | 12 | ||
30 | function clicketyClick() | 13 | FUCKTRAIN="$(dirname "$0")/fucktrain.awk" |
31 | { | 14 | |
32 | if (rand() <= 0.5) { | 15 | case "$(realpath "$(command -v awk)")" in |
33 | return "click " | 16 | *gawk) |
34 | } else { | 17 | AWK=gawk |
35 | return "clickety " | 18 | EXTRA_AWK_ARGS="--characters-as-bytes" # --posix overrides |
36 | } | 19 | ;; |
37 | } | 20 | *mawk) |
21 | AWK=mawk | ||
22 | EXTRA_AWK_ARGS="-Wposix" | ||
23 | ;; | ||
24 | *) | ||
25 | AWK=awk | ||
26 | EXTRA_AWK_ARGS= | ||
27 | ;; | ||
28 | esac | ||
29 | |||
30 | "$AWK" -v EXE_NAME="$(basename $0)" -f "$FUCKTRAIN" $EXTRA_AWK_ARGS -- "$@" | ||