#!/bin/sh # Test stand-in for ssh through dumbpipe: the last argument is the remote command (root@guest: none). # no command: a shell reading stdin ("$ " prompts, echoes each line, exit ends it) # socialweb-guest-agent relay '': relay.mjs, stdin/stdout <-> that socket (the shell parses the quoting) # fail: ssh's own failure (255); anything else: two paced stdout lines, one stderr line, exit 3 for a; do last=$a; done case "$last" in root@guest) printf '$ ' while read -r line; do [ "$line" = exit ] && exit 0 printf '%s\n$ ' "$line" done exit 0 ;; "socialweb-guest-agent relay "*) eval "set -- $last"; exec node "$(dirname "$0")/relay.mjs" "$3" ;; fail) printf 'Host key verification failed.\n' >&2; exit 255 ;; *) printf 'line 1\n'; sleep 0.2; printf 'line 2\n'; sleep 0.2; printf 'oops\n' >&2; exit 3 ;; esac