Shell ===== PytoRuntime includes a shell that can be executed through from :swift:symbol:`Interpreter.run(_:with:enableBreakpoints:)` or :py:meth:`~pyto_runtime.Interpreter.run_shell`. It provides access to various UNIX commands from `ios_system `_, which is used in iOS / iPadOS apps. These commands are embedded in the app and are executed in the same process and can be executed with :py:func:`~patches.os.system` and :py:class:`~patches.subprocess.Popen`. Input ----- The shell uses uses the Python ``readline`` module compiled with BSD ``libedit`` for input, which provides code completion and word navigation. The history is saved in ``~/Documents/.shell_history`` and the ``libedit`` configuration file can be created in ``~/Documents/.editrc``. Commands -------- Type ``help`` in the shell to see a list of available commands. Scripts installed from PyPI or packages embedded in-app will also be recognized by the shell. These scripts are installed in ``~/Documents/.local/bin`` for user installed scripts and ``[...]/site-packages/bin`` for bundled packages. If you want to run a module that has no entrypoint specified in pyproject.toml, you can always run the python interpreter: ``$ python -m my_module``. Operators --------- The shell supports operator for redirecting output and input. Write to file: .. code-block:: $ find . -name "*.py" > scripts.txt Append to file: .. code-block:: $ date >> history.txt Pass file as input: .. code-block:: $ python < my_script.py Hello World! Pass output from a command to another command as input. .. code-block:: $ echo 'print("Hello World!")' | python Hello World! Environment ----------- Environment variables can bet set with ``export``, and read like any other shell. .. code-block:: $ export FOO=BAR $ echo $FOO BAR You can read all the current environment by running ``export`` or ``env`` without arguments.