Skip to content

Instantly share code, notes, and snippets.

@kou029w
Last active January 5, 2021 02:43
Show Gist options
  • Save kou029w/851053e5ad6d8e05fb0c649668795722 to your computer and use it in GitHub Desktop.
Save kou029w/851053e5ad6d8e05fb0c649668795722 to your computer and use it in GitHub Desktop.
a brainfuck compiler written in bash
#!/bin/bash
grep -o . "$@"|sed '/\./cprintf 0x%x $((m[p]))|xxd -r
/\[/cwhile((m[p]));do
/]/cdone
/</c((p--))
/>/c((p++))
s/[+-]/((m[p]&&))/
/^.$/d'
@kou029w
Copy link
Author

kou029w commented Jan 22, 2017

To use

From your command line:

$ ./bf.sh <(echo '+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.')|bash
Hello, world!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment