Something went wrong. Try again.
A rewrite of the Plan 9 rc shell in Goose for UNIX-like systems and with structured CLI args
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930"""Check that the shell processes a pipe before its writer closes it."""import selectimport subprocessimport sysfrom pathlib import Path
TIMEOUT = 4shell = str(Path(sys.argv[1] if len(sys.argv) > 1 else "rc2").resolve())process = subprocess.Popen([shell, "-I"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)try: process.stdin.write(b"echo first\n") process.stdin.flush() ready, _, _ = select.select([process.stdout], [], [], TIMEOUT) assert ready, "The shell waited for EOF before it processed a complete command" assert process.stdout.readline() == b"first\n" process.stdin.write(b"fn f {\necho second\n}\nf") process.stdin.close() assert process.wait(timeout=TIMEOUT) == 0 assert process.stdout.read() == b"second\n" assert process.stderr.read() == b"" print("Stream tests passed")finally: if process.poll() is None: process.kill() process.wait()
result = subprocess.run([shell, "-I"], input=b"echo 'a\x00b'\n", capture_output=True, timeout=TIMEOUT)assert result.returncode == 1 and not result.stdout and result.stderr, "The shell accepted a NUL source byte"