aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-07-02 01:40:32 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-07-02 01:44:41 +1200
commitf60184867b480bba44e5d4470dd8d58882195832 (patch)
tree35ef9cb67c177aa8f473d8c9fd96820dc37969a6 /games
parentVery important addenda to pks(6df) (diff)
downloaddotfiles-f60184867b480bba44e5d4470dd8d58882195832.tar.gz
dotfiles-f60184867b480bba44e5d4470dd8d58882195832.zip
Break pks(6df) and philsay(6df) in two
Looks like awk(1) implementations vary in how they interpret option arguments.
Diffstat (limited to 'games')
-rw-r--r--games/philsay.sh47
-rw-r--r--games/pks.awk80
2 files changed, 53 insertions, 74 deletions
diff --git a/games/philsay.sh b/games/philsay.sh
new file mode 100644
index 00000000..dac2ae6e
--- /dev/null
+++ b/games/philsay.sh
@@ -0,0 +1,47 @@
+#!/bin/shp
+speech=$(pks "$@") || exit
+printf '\n%066s\n' '( '"$speech"' )'
+cat <<'EOF'
+ /
+
+ .''''''''''''''''''''''..
+ .'''''''''''''''''''''''''''
+ .'''''''''''''''''''''''''''''
+ ,'''''''''''''''''''''''''''''''
+ '''''''''''''''''''''''''''''''':
+ ,'''''''''''##`'''''''''''''''.'''`
+ ;''''''''.###########,'''''',###'''
+ ;'''''';#################:'#####.''
+ `:''''''#########################'.
+ ::` ,'+########################';
+ ''''''': .#####################''
+ ''''''''.####` `;#############;##'
+ ;''''''',####,###: +############.
+ ,###''''''#############` ;##:#######
+ ,#:##''';+#####+ :###### +##+ +
+ ,'#;#,''#####',+###` ;####`+
+ ,#'#,#';############++. ,`##
+ :#####+:#######,@,``@@,#####'
+ ;#+#+#############++++##.#+## +
+ ###+################'####'##
+ #######+###################.# :.
+ ######'########################'
+ ,+#####;#######################
+ ,#######;############'####+###:
+ ,#######################+#####'
+ ,###############' ` #'# +'#
+ #,##.###########'##+##'###'####
+ ``@.############## `+#@@@@@######
+ +```@@################ ,,. . ####.
+ ;````@@,##.##############':..:######
+ ;`````@@@########.##################
+ +````````@@@@#####;####################:
+ +`````.`````@@@@######`###################```+
+ +````````,`````'@@@@@##'#####################`````.
++ ``````````.``````@@@@@@##'###'################```````` +
+```````````````````@@@@@@@'#####;##########,##'`````````````.+
+```````````````````@@@@@@@@@+#####':####+:+'````````````````````,
+```````````````````,@@@@@@@@@#:#########'@@@``````````````````````
+```````````.````````@@@@@@@@@@@@#'#####@@@@@```````````````````````
+```````````.````````@@@@@@@@@@@@@@' @@@@@@@.``````````````````````
+EOF
diff --git a/games/pks.awk b/games/pks.awk
index 2219872b..06aad75f 100644
--- a/games/pks.awk
+++ b/games/pks.awk
@@ -3,27 +3,8 @@
# Process arguments
BEGIN {
- # Look for options; keep a count of non-option args
- ac = ARGC
- for (i = 1; i <= ARGC; i++) {
-
- # Show a pic of Phil
- if (ARGV[i] == "--phil") {
- pic = 1
- ARGV[i] = ""
- ac--
- }
-
- # End-of-options
- if (ARGV[i] == "--") {
- break
- ARGV[i] = ""
- ac--
- }
- }
-
# If no arguments left, assume a dictionary file
- if (ac == 1) {
+ if (ARGC == 1) {
ARGC = 2
if ("DICT" in ENVIRON)
ARGV[1] = ENVIRON["DICT"]
@@ -40,10 +21,11 @@ BEGIN {
}
# Iterate over the lines, randomly assigning the first field of each one with a
-# decreasing probability; this method
+# decreasing probability; this method allows a single pass over the input,
+# though it requires a lot of random numbers
$1 ~ /[[:alpha:]]/ && rand() * ++n < 1 { wr = $1 }
-# Ha, ha, ha! Incompetent!
+# Ha, ha! Conclusion!
END {
# Check that we processed at least one line
@@ -61,56 +43,6 @@ END {
# Capitalise the word
wr = toupper(substr(wr,1,1)) substr(wr,2)
- # Return the laughter and the word
- if (pic)
- dopic(ha, wr)
- else
- printf "%s! %s!\n", ha, wr
-}
-
-# Ha, ha! Low-res!
-function dopic(ha, wr) {
- print ""
- print " " ha "! " wr "!"
- print " \\"
- print " .''''''''''''''''''''''.."
- print " .'''''''''''''''''''''''''''"
- print " .'''''''''''''''''''''''''''''"
- print " ,'''''''''''''''''''''''''''''''"
- print " '''''''''''''''''''''''''''''''':"
- print " ,'''''''''''##`'''''''''''''''.'''`"
- print " ;''''''''.###########,'''''',###'''"
- print " ;'''''';#################:'#####.''"
- print " `:''''''#########################'."
- print " ::` ,'+########################';"
- print " ''''''': .#####################''"
- print " ''''''''.####` `;#############;##'"
- print " ;''''''',####,###: +############."
- print " ,###''''''#############` ;##:#######"
- print " ,#:##''';+#####+ :###### +##+ +"
- print " ,'#;#,''#####',+###` ;####`+ "
- print " ,#'#,#';############++. ,`## "
- print " :#####+:#######,@,``@@,#####' "
- print " ;#+#+#############++++##.#+## +"
- print " ###+################'####'## "
- print " #######+###################.# :."
- print " ######'########################'"
- print " ,+#####;#######################"
- print " ,#######;############'####+###:"
- print " ,#######################+#####'"
- print " ,###############' ` #'# +'#"
- print " #,##.###########'##+##'###'####"
- print " ``@.############## `+#@@@@@######"
- print " +```@@################ ,,. . ####."
- print " ;````@@,##.##############':..:######"
- print " ;`````@@@########.##################"
- print " +````````@@@@#####;####################:"
- print " +`````.`````@@@@######`###################```+"
- print " +````````,`````'@@@@@##'#####################`````."
- print "+ ``````````.``````@@@@@@##'###'################```````` +"
- print "```````````````````@@@@@@@'#####;##########,##'`````````````.+"
- print "```````````````````@@@@@@@@@+#####':####+:+'````````````````````,"
- print "```````````````````,@@@@@@@@@#:#########'@@@``````````````````````"
- print "```````````.````````@@@@@@@@@@@@#'#####@@@@@```````````````````````"
- print "```````````.````````@@@@@@@@@@@@@@' @@@@@@@.``````````````````````"
+ # Print the laughter and the word
+ printf "%s! %s!\n", ha, wr
}