make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / override / mesg
blob1f7f28d208b9d7fd23e8e1eeda97de50ad496a72
1 #!/bin/bash
3 set -e
4 set -o pipefail
6 mesg_cmd=`which -a mesg | grep -vx "$0" | head -n1`
8 if [ -n "$STY" -a -n "$GNUSCREEN_WINDOWID" ]
9 then
10 pty=`screen -S "$STY" -p "$GNUSCREEN_WINDOWID" -Q @echo -p %T`
12 if ! expr + "$*" : '.*\(-q\|--quiet\)' >/dev/null
13 then
14 echo "mesg: screen tty is $pty" >&2
17 "$mesg_cmd" "$@" < "/dev/$pty"
19 if [ -n "$1" ]
20 then
21 [ "$1" = y ] && login=on || login=off
22 screen -S "$STY" -p "$GNUSCREEN_WINDOWID" -X @login $login
24 else
25 exec "$mesg_cmd" "$@"