def append_exit()

in src/pathpicker/output.py [0:0]


def append_exit() -> None:
    # The `$SHELL` environment variable points to the default shell,
    # not the current shell. But they are often the same. And there
    # is no other simple and reliable way to detect the current shell.
    shell = os.environ["SHELL"]
    # ``csh``, fish`` and, ``rc`` uses ``$status`` instead of ``$?``.
    if shell.endswith("csh") or shell.endswith("fish") or shell.endswith("rc"):
        exit_status = "$status"
    # Otherwise we assume a Bournal-like shell, e.g. bash and zsh.
    else:
        exit_status = "$?"
    append_to_file(f"exit {exit_status};")