Galaxie Shell 0.2.6 documentation


Navigation:   | Index   | Search   | Top   | Up   |
Table of Content: |

© Copyright 2020-2024, Galaxie Shell Team.

Top » Module code » glxshell.utilities.tty

Source code for glxshell.utilities.tty

# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/tty.html

import os
import sys
from glxshell.lib.argparse import ArgumentParser
from glxshell.lib.utils import error_code_to_text

parser_tty = ArgumentParser(
    name="tty - return user's terminal name",
    description="The tty utility shall write to the standard output the name of the terminal that is open as standard "
    "input.",
)


[docs] def glxsh_tty(): try: sys.stdout.write("%s\n" % os.ttyname(sys.stdin.fileno())) return 0 except OSError: sys.stdout.write("not a tty\n") return 1 except (Exception, ArithmeticError) as error: # pragma: no cover sys.stderr.write("tty: %s\n" % (error_code_to_text(error.errno))) return 1

Top » Module code » glxshell.utilities.tty

© Copyright 2020-2024, Galaxie Shell Team.
This page is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0).
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

Last updated on None.
Created using Sphinx 8.0.2.