mirror of
https://repo.or.cz/socat.git
synced 2025-07-19 09:22:57 +00:00
Further improved readline.sh STDERR handling
This commit is contained in:
parent
4ee1f31cf8
commit
69c9eb550c
3 changed files with 25 additions and 8 deletions
22
readline.sh
22
readline.sh
|
@ -4,15 +4,19 @@
|
|||
# Published under the GNU General Public License V.2, see file COPYING
|
||||
|
||||
# this is an attempt for a socat based readline wrapper
|
||||
# usage: readline.sh <command>
|
||||
# usage: readline.sh [options] <program>
|
||||
|
||||
withhistfile=1
|
||||
|
||||
STDERR=
|
||||
while true; do
|
||||
case "X$1" in
|
||||
X-nh|X-nohist*) withhistfile=; shift; continue ;;
|
||||
*) break;;
|
||||
X-lf?*) STDERR="${1:3}" ;;
|
||||
X-lf) shift; STDERR="$1" ;;
|
||||
X-nh|X-nohist*) withhistfile= ;;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
PROGRAM="$@"
|
||||
|
@ -25,12 +29,18 @@ fi
|
|||
#
|
||||
#
|
||||
|
||||
if test -w .; then
|
||||
#if test -w .; then
|
||||
if [ -z "$STDERR" ] && find . -maxdepth 0 -user $USER ! -perm /022 -print |grep ^ >/dev/null; then
|
||||
# When cwd is owned by $USER and it is neither group nor world writable
|
||||
STDERR=./socat-readline.${1##*/}.log
|
||||
rm -f $STDERR
|
||||
else
|
||||
echo "$0: logs go to $STDERR" >&2
|
||||
elif [ -z "$STDERR" ]; then
|
||||
echo "$0: insecure working directory, no logs are written" >&2
|
||||
STDERR=/dev/null
|
||||
else
|
||||
echo "$0: logs go to $STDERR" >&2
|
||||
fi
|
||||
|
||||
exec socat -d readline"$HISTOPT",noecho='[Pp]assword:' exec:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>$STDERR
|
||||
exec socat -d READLINE"$HISTOPT",noecho='[Pp]assword:' EXEC:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>$STDERR
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue