#!/usr/bin/env python3 from pexpect_helper import SpawnedProc import subprocess import sys import time sp = SpawnedProc() send, sendline, sleep, expect_prompt, expect_re, expect_str = ( sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re, sp.expect_str, ) expect_prompt() sendline("test -t 0; echo $status") expect_prompt("0") sendline("""function t test -t 0 && echo stdin test -t 1 && echo stdout test -t 2 && echo stderr end""") expect_prompt() sendline("t") expect_str("stdin") expect_str("stdout") expect_str("stderr") expect_prompt() sendline("cat | cat") expect_str("stdin") expect_str("stdout") expect_prompt() sendline("cat | cat") expect_str("stdout") expect_prompt() sendline("t