5 ms·
I am shocked how readable the code is. Was expecting some Perl-like spaghetti.
by oweiler 4y ago
I am shocked how readable the code is. Was expecting some Perl-like spaghetti.
- userbinator 4y agoYou could say that the code isn't really awkward to read.
- amalgamated_inc 4y agoThat's what she sed
- gchamonlive 4y agoMom! They spilled Reddit all over my hackernews!
- amalgamated_inc 4y agoGo ask your father.
- ufo 4y agoI was hoping for some clever abuse of AWK's patterns & regexes but clean code will also do :)
- mths 4y agoFor 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.
- ufo 4y agoWow
- nsxwolf 4y agoI always avoided awk because I thought it was just a really weird looking alternative to sed. When it's nicely formatted like this it looks like a perfectly sensible C-like language.
- mseepgood 4y agoAwk reads quite javascripty. JavaScript's function syntax was copied from awk.