diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index c2d3eb1c..972a2be4 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2695,9 +2695,11 @@ Usage:  Usage: unalias [-a] name [name ...]
         Non-python commands can be issued with ``pyscript_name("your command")``.
         Run python code from external script files with ``run("script.py")``
         """
-        from .pyscript_bridge import PyscriptBridge
+        from .pyscript_bridge import PyscriptBridge, CommandResult
         if self._in_py:
-            self.perror("Recursively entering interactive Python consoles is not allowed.", traceback_war=False)
+            err = "Recursively entering interactive Python consoles is not allowed."
+            self.perror(err, traceback_war=False)
+            self._last_result = CommandResult('', err)
             return False
         self._in_py = True
 

Manual unit test failures on some Linux systems
I just manually ran unit tests on a Debian 9.5 system with Python 3.6 installed using conda and encountered some unit test failures in the pyscript tests.

I suspect the changes may relate to the recent StdSim PR where the new StdSim class replaced the old CopyStream class used by pyscript_bridge.py.

I do **NOT** see manual unit test failures on any of the following systems:
* macOS
* Windows
* Ubuntu 18.04
* Ubuntu 18.04 via Windows Subsystem for Linux (WSL)

So this issue is isolated to some particular versions of Linux and/or some particular versions of Python on Linux.
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 7a8a52a0..99c30af4 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -220,13 +220,13 @@ def test_base_run_pyscript(base_app, capsys, request):
     out, err = capsys.readouterr()
     assert out == expected
 
-def test_recursive_pyscript_not_allowed(base_app, capsys, request):
+def test_recursive_pyscript_not_allowed(base_app, request):
     test_dir = os.path.dirname(request.module.__file__)
     python_script = os.path.join(test_dir, 'scripts', 'recursive.py')
-    expected = 'ERROR: Recursively entering interactive Python consoles is not allowed.\n'
+    expected = 'Recursively entering interactive Python consoles is not allowed.'
 
     run_cmd(base_app, "pyscript {}".format(python_script))
-    out, err = capsys.readouterr()
+    err = base_app._last_result.stderr
     assert err == expected
 
 def test_pyscript_with_nonexist_file(base_app, capsys):
diff --git a/tests/test_pyscript.py b/tests/test_pyscript.py
index 256e63a7..d5e5a4fb 100644
--- a/tests/test_pyscript.py
+++ b/tests/test_pyscript.py
@@ -20,7 +20,7 @@ class PyscriptExample(Cmd):
         if not args.command:
             self.do_help(['media movies'])
         else:
-            print('media movies ' + str(args.__dict__))
+            self.poutput('media movies ' + str(args.__dict__))
 
     def _do_media_shows(self, args) -> None:
         if not args.command:
@@ -29,7 +29,7 @@ class PyscriptExample(Cmd):
         if not args.command:
             self.do_help(['media shows'])
         else:
-            print('media shows ' + str(args.__dict__))
+            self.poutput('media shows ' + str(args.__dict__))
 
     media_parser = argparse_completer.ACArgumentParser(prog='media')
 
@@ -84,7 +84,7 @@ class PyscriptExample(Cmd):
 
     @with_argparser(foo_parser)
     def do_foo(self, args):
-        print('foo ' + str(args.__dict__))
+        self.poutput('foo ' + str(args.__dict__))
         if self._in_py:
             FooResult = namedtuple_with_defaults('FooResult',
                                                  ['counter', 'trueval', 'constval',
@@ -110,7 +110,7 @@ class PyscriptExample(Cmd):
         out += '{'
         for key in keys:
             out += "'{}':'{}'".format(key, arg_dict[key])
-        print(out)
+        self.poutput(out)
 
 
 @pytest.fixture
@@ -126,7 +126,7 @@ class PyscriptCustomNameExample(Cmd):
         self.pyscript_name = 'custom'
 
     def do_echo(self, out):
-        print(out)
+        self.poutput(out)
 
 
 @pytest.fixture
@@ -140,7 +140,7 @@ def ps_echo():
     ('help', 'help.py'),
     ('help media', 'help_media.py'),
 ])
-def test_pyscript_help(ps_app, capsys, request, command, pyscript_file):
+def test_pyscript_help(ps_app, request, command, pyscript_file):
     test_dir = os.path.dirname(request.module.__file__)
     python_script = os.path.join(test_dir, 'pyscript', pyscript_file)
     expected = run_cmd(ps_app, command)
@@ -169,16 +169,14 @@ def test_pyscript_help(ps_app, capsys, request, command, pyscript_file):
     ('foo 11 22 33 44 55 66 -ccc', 'foo3.py'),
     ('bar 11 22', 'bar1.py'),
 ])
-def test_pyscript_out(ps_app, capsys, request, command, pyscript_file):
+def test_pyscript_out(ps_app, request, command, pyscript_file):
     test_dir = os.path.dirname(request.module.__file__)
     python_script = os.path.join(test_dir, 'pyscript', pyscript_file)
-    run_cmd(ps_app, command)
-    expected, _ = capsys.readouterr()
+    expected = run_cmd(ps_app, command)
+    assert expected
 
-    assert len(expected) > 0
-    run_cmd(ps_app, 'pyscript {}'.format(python_script))
-    out, _ = capsys.readouterr()
-    assert len(out) > 0
+    out = run_cmd(ps_app, 'pyscript {}'.format(python_script))
+    assert out
     assert out == expected
 
 
@@ -227,14 +225,12 @@ def test_pyscript_dir(ps_app, capsys, request, expected, pyscript_file):
     assert out == expected
 
 
-def test_pyscript_custom_name(ps_echo, capsys, request):
+def test_pyscript_custom_name(ps_echo, request):
     message = 'blah!'
 
     test_dir = os.path.dirname(request.module.__file__)
     python_script = os.path.join(test_dir, 'pyscript', 'custom_echo.py')
 
-    run_cmd(ps_echo, 'pyscript {}'.format(python_script))
-    expected, _ = capsys.readouterr()
-    assert len(expected) > 0
-    expected = expected.splitlines()
-    assert message == expected[0]
+    out = run_cmd(ps_echo, 'pyscript {}'.format(python_script))
+    assert out
+    assert message == out[0]

pip install -e .[dev]
parse_log_pytest
pytest
pytest codecov
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.16
anyio==4.9.0
astroid==3.3.9
attrs==25.3.0
babel==2.17.0
backports.tarfile==1.2.0
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
-e git+https://github.com/python-cmd2/cmd2.git@c8890646d88fab3e07ccd71b30c2fed3785a7d5e#egg=cmd2
codecov==2.1.13
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
dill==0.3.9
distlib==0.3.9
docutils==0.21.2
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
filelock==3.18.0
h11==0.14.0
id==1.5.0
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
invoke==2.2.0
isort==6.0.1
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
keyring==25.6.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mccabe==0.7.0
mdurl==0.1.2
more-itertools==10.6.0
nh3==0.2.21
packaging @ file:///croot/packaging_1734472117206/work
platformdirs==4.3.7
pluggy @ file:///croot/pluggy_1733169602837/work
pycparser==2.22
Pygments==2.19.1
pylint==3.3.6
pyperclip==1.9.0
pyproject-api==1.9.0
pytest @ file:///croot/pytest_1738938843180/work
pytest-cov==6.0.0
pytest-mock==3.14.0
readme_renderer==44.0
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==14.0.0
SecretStorage==3.3.3
sniffio==1.3.1
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-autobuild==2024.10.3
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
starlette==0.46.1
tomli==2.2.1
tomlkit==0.13.2
tox==4.25.0
twine==6.1.0
typing_extensions==4.13.0
urllib3==2.3.0
uvicorn==0.34.0
virtualenv==20.29.3
watchfiles==1.0.4
wcwidth==0.2.13
websockets==15.0.1
zipp==3.21.0

name: cmd2
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.16
      - anyio==4.9.0
      - astroid==3.3.9
      - attrs==25.3.0
      - babel==2.17.0
      - backports-tarfile==1.2.0
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cffi==1.17.1
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - codecov==2.1.13
      - colorama==0.4.6
      - coverage==7.8.0
      - cryptography==44.0.2
      - dill==0.3.9
      - distlib==0.3.9
      - docutils==0.21.2
      - filelock==3.18.0
      - h11==0.14.0
      - id==1.5.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==8.6.1
      - invoke==2.2.0
      - isort==6.0.1
      - jaraco-classes==3.4.0
      - jaraco-context==6.0.1
      - jaraco-functools==4.1.0
      - jeepney==0.9.0
      - jinja2==3.1.6
      - keyring==25.6.0
      - markdown-it-py==3.0.0
      - markupsafe==3.0.2
      - mccabe==0.7.0
      - mdurl==0.1.2
      - more-itertools==10.6.0
      - nh3==0.2.21
      - platformdirs==4.3.7
      - pycparser==2.22
      - pygments==2.19.1
      - pylint==3.3.6
      - pyperclip==1.9.0
      - pyproject-api==1.9.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - readme-renderer==44.0
      - requests==2.32.3
      - requests-toolbelt==1.0.0
      - rfc3986==2.0.0
      - rich==14.0.0
      - secretstorage==3.3.3
      - sniffio==1.3.1
      - snowballstemmer==2.2.0
      - sphinx==7.4.7
      - sphinx-autobuild==2024.10.3
      - sphinx-rtd-theme==3.0.2
      - sphinxcontrib-applehelp==2.0.0
      - sphinxcontrib-devhelp==2.0.0
      - sphinxcontrib-htmlhelp==2.1.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==2.0.0
      - sphinxcontrib-serializinghtml==2.0.0
      - starlette==0.46.1
      - tomli==2.2.1
      - tomlkit==0.13.2
      - tox==4.25.0
      - twine==6.1.0
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - uvicorn==0.34.0
      - virtualenv==20.29.3
      - watchfiles==1.0.4
      - wcwidth==0.2.13
      - websockets==15.0.1
      - zipp==3.21.0
prefix: /opt/conda/envs/cmd2

tests/test_cmd2.py::test_recursive_pyscript_not_allowed
tests/test_cmd2.py::test_which_editor_good
tests/test_cmd2.py::test_version tests/test_cmd2.py::test_empty_statement tests/test_cmd2.py::test_base_help tests/test_cmd2.py::test_base_help_verbose tests/test_cmd2.py::test_base_help_history tests/test_cmd2.py::test_base_argparse_help tests/test_cmd2.py::test_base_invalid_option tests/test_cmd2.py::test_base_shortcuts tests/test_cmd2.py::test_base_show tests/test_cmd2.py::test_base_show_long tests/test_cmd2.py::test_base_show_readonly tests/test_cmd2.py::test_cast tests/test_cmd2.py::test_cast_problems tests/test_cmd2.py::test_base_set tests/test_cmd2.py::test_set_not_supported tests/test_cmd2.py::test_set_quiet tests/test_cmd2.py::test_base_shell tests/test_cmd2.py::test_base_py tests/test_cmd2.py::test_base_run_python_script tests/test_cmd2.py::test_base_run_pyscript tests/test_cmd2.py::test_pyscript_with_nonexist_file tests/test_cmd2.py::test_pyscript_with_exception tests/test_cmd2.py::test_pyscript_requires_an_argument tests/test_cmd2.py::test_base_error tests/test_cmd2.py::test_history_span tests/test_cmd2.py::test_history_get tests/test_cmd2.py::test_base_history tests/test_cmd2.py::test_history_script_format tests/test_cmd2.py::test_history_with_string_argument tests/test_cmd2.py::test_history_with_integer_argument tests/test_cmd2.py::test_history_with_integer_span tests/test_cmd2.py::test_history_with_span_start tests/test_cmd2.py::test_history_with_span_end tests/test_cmd2.py::test_history_with_span_index_error tests/test_cmd2.py::test_history_output_file tests/test_cmd2.py::test_history_edit tests/test_cmd2.py::test_history_run_all_commands tests/test_cmd2.py::test_history_run_one_command tests/test_cmd2.py::test_history_clear tests/test_cmd2.py::test_base_load tests/test_cmd2.py::test_load_with_empty_args tests/test_cmd2.py::test_load_with_nonexistent_file tests/test_cmd2.py::test_load_with_directory tests/test_cmd2.py::test_load_with_empty_file tests/test_cmd2.py::test_load_with_binary_file tests/test_cmd2.py::test_load_with_utf8_file tests/test_cmd2.py::test_load_nested_loads tests/test_cmd2.py::test_base_runcmds_plus_hooks tests/test_cmd2.py::test_base_relative_load tests/test_cmd2.py::test_relative_load_requires_an_argument tests/test_cmd2.py::test_output_redirection tests/test_cmd2.py::test_output_redirection_to_nonexistent_directory tests/test_cmd2.py::test_output_redirection_to_too_long_filename tests/test_cmd2.py::test_feedback_to_output_true tests/test_cmd2.py::test_feedback_to_output_false tests/test_cmd2.py::test_allow_redirection tests/test_cmd2.py::test_pipe_to_shell tests/test_cmd2.py::test_pipe_to_shell_error tests/test_cmd2.py::test_base_timing tests/test_cmd2.py::test_base_debug tests/test_cmd2.py::test_base_colorize tests/test_cmd2.py::test_edit_no_editor tests/test_cmd2.py::test_edit_file tests/test_cmd2.py::test_edit_file_with_spaces tests/test_cmd2.py::test_edit_blank tests/test_cmd2.py::test_base_py_interactive tests/test_cmd2.py::test_exclude_from_history tests/test_cmd2.py::test_base_cmdloop_with_queue tests/test_cmd2.py::test_base_cmdloop_without_queue tests/test_cmd2.py::test_cmdloop_without_rawinput tests/test_cmd2.py::test_precmd_hook_success tests/test_cmd2.py::test_precmd_hook_failure tests/test_cmd2.py::test_interrupt_quit tests/test_cmd2.py::test_interrupt_noquit tests/test_cmd2.py::test_default_to_shell_unknown tests/test_cmd2.py::test_default_to_shell_good tests/test_cmd2.py::test_default_to_shell_failure tests/test_cmd2.py::test_ansi_prompt_not_esacped tests/test_cmd2.py::test_ansi_prompt_escaped tests/test_cmd2.py::test_custom_command_help tests/test_cmd2.py::test_custom_help_menu tests/test_cmd2.py::test_help_undocumented tests/test_cmd2.py::test_help_overridden_method tests/test_cmd2.py::test_help_cat_base tests/test_cmd2.py::test_help_cat_verbose tests/test_cmd2.py::test_select_options tests/test_cmd2.py::test_select_invalid_option tests/test_cmd2.py::test_select_list_of_strings tests/test_cmd2.py::test_select_list_of_tuples tests/test_cmd2.py::test_select_uneven_list_of_tuples tests/test_cmd2.py::test_help_with_no_docstring tests/test_cmd2.py::test_which_editor_bad tests/test_cmd2.py::test_multiline_complete_empty_statement_raises_exception tests/test_cmd2.py::test_multiline_complete_statement_without_terminator tests/test_cmd2.py::test_multiline_complete_statement_with_unclosed_quotes tests/test_cmd2.py::test_clipboard_failure tests/test_cmd2.py::test_commandresult_truthy tests/test_cmd2.py::test_commandresult_falsy tests/test_cmd2.py::test_is_text_file_bad_input tests/test_cmd2.py::test_eof tests/test_cmd2.py::test_eos tests/test_cmd2.py::test_echo tests/test_cmd2.py::test_pseudo_raw_input_tty_rawinput_true tests/test_cmd2.py::test_pseudo_raw_input_tty_rawinput_false tests/test_cmd2.py::test_pseudo_raw_input_piped_rawinput_true_echo_true tests/test_cmd2.py::test_pseudo_raw_input_piped_rawinput_true_echo_false tests/test_cmd2.py::test_pseudo_raw_input_piped_rawinput_false_echo_true tests/test_cmd2.py::test_pseudo_raw_input_piped_rawinput_false_echo_false tests/test_cmd2.py::test_raw_input tests/test_cmd2.py::test_stdin_input tests/test_cmd2.py::test_empty_stdin_input tests/test_cmd2.py::test_poutput_string tests/test_cmd2.py::test_poutput_zero tests/test_cmd2.py::test_poutput_empty_string tests/test_cmd2.py::test_poutput_none tests/test_cmd2.py::test_alias tests/test_cmd2.py::test_alias_with_quotes tests/test_cmd2.py::test_alias_lookup_invalid_alias tests/test_cmd2.py::test_unalias tests/test_cmd2.py::test_unalias_all tests/test_cmd2.py::test_unalias_non_existing tests/test_cmd2.py::test_create_invalid_alias[">"] tests/test_cmd2.py::test_create_invalid_alias["no>pe"] tests/test_cmd2.py::test_create_invalid_alias["no tests/test_cmd2.py::test_create_invalid_alias["nopipe|"] tests/test_cmd2.py::test_create_invalid_alias["noterm;"] tests/test_cmd2.py::test_create_invalid_alias[noembedded"quotes] tests/test_cmd2.py::test_complete_unalias tests/test_cmd2.py::test_ppaged tests/test_cmd2.py::test_parseline_empty tests/test_cmd2.py::test_parseline tests/test_cmd2.py::test_readline_remove_history_item tests/test_cmd2.py::test_onecmd_raw_str_continue tests/test_cmd2.py::test_onecmd_raw_str_quit tests/test_cmd2.py::test_existing_history_file tests/test_cmd2.py::test_new_history_file tests/test_cmd2.py::test_bad_history_file_path tests/test_cmd2.py::test_get_all_commands tests/test_cmd2.py::test_get_help_topics tests/test_cmd2.py::test_exit_code_default tests/test_cmd2.py::test_exit_code_nonzero tests/test_pyscript.py::test_pyscript_help[help-help.py] tests/test_pyscript.py::test_pyscript_help[help tests/test_pyscript.py::test_pyscript_out[media tests/test_pyscript.py::test_pyscript_out[foo tests/test_pyscript.py::test_pyscript_out[bar tests/test_pyscript.py::test_pyscript_errors[app.noncommand-AttributeError] tests/test_pyscript.py::test_pyscript_errors[app.media.noncommand-AttributeError] tests/test_pyscript.py::test_pyscript_errors[app.media.movies.list(artist="Invalid tests/test_pyscript.py::test_pyscript_errors[app.foo(counter="a")-TypeError] tests/test_pyscript.py::test_pyscript_errors[app.foo("aaa")-ValueError] tests/test_pyscript.py::test_pyscript_results[foo4.py-Success] tests/test_pyscript.py::test_pyscript_dir[['_relative_load', tests/test_pyscript.py::test_pyscript_dir[['movies', tests/test_pyscript.py::test_pyscript_custom_name
cmd2/cmd2.py
cmd2/cmd2.py