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 5 6# this is an attempt for a socat based readline wrapper 7# usage: readline.sh <command> 8 9withhistfile=1 10 11while true; do 12 case "X$1" in 13 X-nh|X-nohist*) withhistfile=; shift; continue ;; 14 *) break;; 15 esac 16done 17 18PROGRAM="$@" 19if [ "$withhistfile" ]; then 20 HISTFILE="$HOME/.$1_history" 21 HISTOPT=",history=$HISTFILE" 22else 23 HISTOPT= 24fi 25mkdir -p /tmp/$USER || exit 1 26# 27# 28 29exec socat -d readline"$HISTOPT",noecho='[Pp]assword:' exec:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>/tmp/$USER/stderr2 30 31