Re:A first person shooter in 571 lines of GNU Awk (2017)
by ufo on Thursday January 19, 2023 @04:22PM
(#34445784)
I was hoping for some clever abuse of AWK's patterns & regexes but clean code will also do :)
[ Parent
| on HN ]
Re:A first person shooter in 571 lines of GNU Awk (2017)
by mths on Thursday January 19, 2023 @06:26PM
(#34447097)
For that, to start with, you'd need to be able to create a feedback loop of awk's output back to itself as input. For it not to interfere with rendering, it needs to be on a separate file descriptor from stdout.
I found this snippet on stackexchange showing how exactly that is possible on Linux.
> echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
This "renders" on stdout then feeds itself more input on /dev/fd/3.