From deeb9792ba4b6a8df68017c0a671554a6b87065b Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 7 Jun 2022 07:13:13 +0200 Subject: [PATCH] add wat --- wat/README.md | 1 + wat/set-e.sh | 31 +++++++++++++++++++++++++++++++ wat/upperlower.py | 15 +++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 wat/README.md create mode 100644 wat/set-e.sh create mode 100644 wat/upperlower.py diff --git a/wat/README.md b/wat/README.md new file mode 100644 index 0000000..4f6f9b1 --- /dev/null +++ b/wat/README.md @@ -0,0 +1 @@ +observe surprising things about programming languages. diff --git a/wat/set-e.sh b/wat/set-e.sh new file mode 100644 index 0000000..995f165 --- /dev/null +++ b/wat/set-e.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh +# run this shell script with one of these shells: +# zsh, bash, dash, or (busybox) ash. +set -e + +# false # this exits the shell immediately. +# false || false # this exits as well. +false && true # wait, what? +! true # huh? + +fun() { + false # this *should* cause, the shell to exit, right...? + [ "$1" = 0 ] +} + +if fun 0; then echo wat 1; fi +if false; then echo nope; elif fun 0; then echo wat 2; fi + +i=0 +while fun $i; do i=1; done +until fun $i; do i=0; done + +# ! fun 0 # this exits zsh, and only zsh. +# (! (! fun 0)) # this exits bash, and only bash. +fun 0 && echo wat 3 || echo nope +fun 1 && echo nope +fun 0 || echo nope + +echo aborting... +fun 0 # let's get out of here. +echo at least that works. diff --git a/wat/upperlower.py b/wat/upperlower.py new file mode 100644 index 0000000..5f6db51 --- /dev/null +++ b/wat/upperlower.py @@ -0,0 +1,15 @@ +a = "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸŠŒŽ" +b = "abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿšœž" + +# try this for fun, if breaking things is fun to you: +a += "ß" +b += "ß" + +print(a) +print(b.upper()) +print(a.lower()) +print(b) + +print("TEST:") +print(a == b.upper()) +print(b == a.lower())