2 # source: readline-test.sh
3 # Copyright Gerhard Rieger 2003-2008
4 # Published under the GNU General Public License V.2, see file COPYING
6 # script that simulates a simple program with authentication.
7 # is just for testing the readline features
8 # perform the test with something like:
9 # ./socat readline,history=$HOME/.history,noecho='^Password: ' system:./readline-test.sh,pty,setsid,ctty,stderr,sigint,sigquit,echo=0,raw
12 BANNER
='readline feature test program'
13 USERPROMPT
='Authentication required\nUsername: '
14 PWDPROMPT
='Password: '
17 # degenerated user database
21 if [ $
(echo "x\c") = "x" ]; then ECHO
="echo"
22 elif [ $
(echo -e "x\c") = "x" ]; then ECHO
="echo -e"
25 #trap "$ECHO $0 got SIGINT" INT
26 trap "$ECHO $0 got SIGINT" INT
27 trap "$ECHO $0 got SIGQUIT" QUIT
32 # on (some) ksh read -p does not mean prompt
33 $ECHO "$USERPROMPT\c"; read -r USERNAME
34 $ECHO "$PWDPROMPT\c"; read -rs PASSWORD
37 if [ "$USERNAME" != "$CREDUSER" -o "$PASSWORD" != "$CREDPASS" ]; then
38 $ECHO "Authentication failed" >&2
42 while $ECHO "$PROMPT\c"; read -r COMMAND
; do
43 if [ "$COMMAND" = "exit" ]; then
46 $ECHO "executing $COMMAND"