Version 1.8.0.0
[socat.git] / readline.sh
blobb6f84381fd1bbe23c3e0e63e20f67d801e5e6db0
1 #! /usr/bin/env bash
2 # source: readline.sh
3 # Copyright Gerhard Rieger and contributors (see file CHANGES)
4 # Published under the GNU General Public License V.2, see file COPYING
6 # this is an attempt for a socat based readline wrapper
7 # usage: readline.sh <command>
9 withhistfile=1
11 while true; do
12 case "X$1" in
13 X-nh|X-nohist*) withhistfile=; shift; continue ;;
14 *) break;;
15 esac
16 done
18 PROGRAM="$@"
19 if [ "$withhistfile" ]; then
20 HISTFILE="$HOME/.$1_history"
21 HISTOPT=",history=$HISTFILE"
22 else
23 HISTOPT=
25 mkdir -p /tmp/$USER || exit 1
29 exec socat -d readline"$HISTOPT",noecho='[Pp]assword:' exec:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>/tmp/$USER/stderr2