Thanks to a question on superuser.com, I found out about this utterly convenient rlwrap tool.
It satisfies my needs (i.e. add command history to another cmdline tool), but I was wondering how I can use it to add command history to a 'compound' shell command, like the prototypical
$> while read line; do echo "i read $line"; done
hi
i read hi
^D
When I put the while loop inside a shell script, and execute it like rlwrap ./whilereadline.sh, it's ok.
But I'm wondering how I can do this without the need for an additional file, somewhat like
$> rlwrap (while read line; do echo "line: $line"; done)
bash: syntax error near unexpected token `while'
Any ideas?