Today I will present misc/rlwrap which is an utility tool when you use some command-line software which doesn’t provide you a nice readline input. By using rlwrap, you will be able to use telnet, a language REPL or any command-line tool where you input text with an history of what you type, ability to use emacs bindings like C-a C-e M-Ret etc… I use it often with telnet or sbcl.
rlwrap telnet host port
If you want to write a script reading stdin and put it into a variable, there is an very easy way to procede :
#!/bin/sh var=`cat` echo $var