This bug has been bothering me for a while. When you do something like the commands below, you'd get bombarded by a wall of Python command prompts (>>> ).
$ echo 'foo' | ./bin/lldb -o script
$ cat /tmp/script script print("foo") $ lldb --source /tmp/script
The issue is that our custom input reader doesn't handle EOF. According to the Python documentation, file.readline always includes a trailing newline character unless the file ends with an incomplete line. Therefore, checking for the empty string before stripping it tells us if we've read EOF.
[1] https://docs.python.org/2/library/stdtypes.html#file.readline
# Empty line from readline indicates EOF