context: shells want to leave the seek position at the right offset so external commands can continue reading from the same fd
i saw this somewhat surprising tally of syscalls in bash. let's investigate
one iteration:
- unblock all signals
| 1s/^/1 / | |
| 2,$g/^/-t -\ | |
| s/ .*//\ | |
| s/^9*$/0&/\ | |
| t .\ | |
| s/^.*[^9]\(9*\)$/\1 /\ | |
| s/9/0/g\ | |
| -s/9*$//\ | |
| s/8$/9/\ | |
| s/7$/8/\ |
Last major change: 10th March 2023
| #!/bin/bash | |
| shopt -s expand_aliases extglob | |
| __eval () { | |
| unset __code __tmp __commands | |
| while (( $# )); do | |
| if [[ $1 && $1 = *[![:space:]]* ]]; then | |
| printf "==== command ====\n%s\n=================\n" "$1" | |
| time eval "$1" | |
| fi |
| #!/bin/bash | |
| save=$(bind -p; bind -X) | |
| function clean-up { | |
| bind -r '\C-i' | |
| bind -f /dev/stdin <<< "$save" | |
| } | |
| trap 'clean-up' RETURN | |
| function write-options { |
| test |
korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).
korn.hint, as the name implies, offers some hints.
A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.
=====
Here's the code:
| #! /usr/bin/env python | |
| """ Convert values between RGB hex codes and xterm-256 color codes. | |
| Nice long listing of all 256 colors and their codes. Useful for | |
| developing console color themes, or even script output schemes. | |
| Resources: | |
| * http://en.wikipedia.org/wiki/8-bit_color | |
| * http://en.wikipedia.org/wiki/ANSI_escape_code |