Skip to content

Instantly share code, notes, and snippets.

@rolfwr
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfwr/aec4daf4789e8374b6f6 to your computer and use it in GitHub Desktop.
Save rolfwr/aec4daf4789e8374b6f6 to your computer and use it in GitHub Desktop.
Hello world in C# compiled to .NET IL, and then compiled down to a stand-alone portable Bourne shell
#! /bin/sh
LC_CTYPE=C; export LC_CTYPE
charat() { if test -z $BASH; then r=$(expr substr $1 $(($2 + 1)) 1); else r=${1:$2:1}; fi }
p=0
h=0
i=0
while true; do
case $i in
0)
# IL_0000: ldstr "Hello World!"
eval "s${p}=\"Hello World!\""
# IL_0005: call System.Void System.Console::WriteLine(System.String)
eval "a1=\$s${p}"
echo "${a1}"
# IL_000a: ret
break
exit 1
;;
esac
done
#! /bin/sh
LC_CTYPE=C; export LC_CTYPE
charat() { if test -z $BASH; then r=$(expr substr $1 $(($2 + 1)) 1); else r=${1:$2:1}; fi }
p=0
h=0
i=0
while true; do
case $i in
0)
eval "s${p}=\"Hello World!\""
eval "a1=\$s${p}"
echo "${a1}"
break
exit 1
;;
esac
done
internal static void HelloWorldCSharp()
{
Console.WriteLine("Hello World!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment