TSORT(1P)

πŸ’– TSORT(1P) β€” the POSIX Programmer's Manual page, bestie edition πŸ’–

okay so hi!! welcome to tsort, from the POSIX Programmer's Manual (yes the whole manual, she's part of a set πŸ‘‘). buckle up.

🌸 PROLOG 🌸

so real talk first: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β€” like, go check the corresponding Linux manual page for the actual Linux behavior, okay? or honestly it might not even be implemented on Linux at all. no cap. πŸ™ˆ


✨ NAME ✨

tsort β€” topological sort. that's the whole vibe. sorting but make it graph theory.


✨ SYNOPSIS ✨

tsort [file]

that's it. one optional little operand. she's low maintenance πŸ’…


✨ DESCRIPTION ✨

so the tsort utility shall write to standard output a totally ordered list of items, consistent with a partial ordering of items contained in the input. like, you give her a bunch of "this comes before that" hints, and she hands you back one whole order that doesn't break any of them. iconic behavior honestly.

the application shall ensure that the input consists of pairs of items (non-empty strings) separated by <blank> characters.

  • pairs of different items β†’ that's an ordering. "a before b", noted.
  • pairs of identical items β†’ that's a presence, but not an ordering. just vibes, no rank.

✨ OPTIONS ✨

None. literally zero. she has no flags, she needs no flags, she's perfect as she is πŸ’–


✨ OPERANDS ✨

the following operand shall be supported:

  • file β€” a pathname of a text file to order. if you don't pass a file operand, standard input shall be used instead. πŸŽ€

✨ STDIN ✨

the standard input shall be used if no file operand is specified. it also shall be used if the file operand is - and the implementation treats the - as meaning standard input. otherwise? standard input shall not be used. see the INPUT FILES section, bestie, i'm not repeating myself (i am, slightly).


✨ INPUT FILES ✨

the input file shall be a text file. that's the requirement. a text file. πŸ“„


✨ ENVIRONMENT VARIABLES ✨

the following environment variables shall affect the execution of tsort:

  • LANG β€” provides a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1‐2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
  • LC_ALL β€” if set to a non-empty string value, this one overrides the values of all the other internationalization variables. she's the main character, she wins every argument πŸ‘‘
  • LC_CTYPE β€” determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files).
  • LC_MESSAGES β€” determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
  • NLSPATH β€” determines the location of message catalogs for the processing of LC_MESSAGES.

✨ ASYNCHRONOUS EVENTS ✨

Default. no drama, standard behavior, she's chill πŸ¦‹


✨ STDOUT ✨

the standard output shall be a text file consisting of the order list produced from the partially ordered input. that's the whole point. that's the gift. 🎁


✨ STDERR ✨

standard error shall be used only for diagnostic messages. only. exclusively. she's not chatty for no reason.


✨ OUTPUT FILES ✨

None. nope. nothing. she prints to stdout and that's the end of it πŸ’€


✨ EXTENDED DESCRIPTION ✨

None. there is no extended description. there is only the description you already read. periodt.


✨ EXIT STATUS ✨

the following exit values shall be returned:

  1. 0 β€” successful completion. slay ✨
  2. >0 β€” an error occurred. 😭

✨ CONSEQUENCES OF ERRORS ✨

Default.

the following sections are informative. (yes, that's literally what the page says right here, so here it is.)


✨ APPLICATION USAGE ✨

real talk: the LC_COLLATE variable need not affect the actions of tsort. the output ordering is not lexicographic β€” it depends on the pairs of items given as input. so don't come at her expecting alphabetical, she's doing topology, not dictionary. iykyk πŸ”₯


✨ EXAMPLES ✨

okay bestie, watch this. the command:

tsort <<EOF
a b c c d e
g g
f g e f
h h
EOF

produces the output:

a
b
c
d
e
f
g
h

look at that. one item per line, fully ordered, every pair respected. ate and left no crumbs πŸ’…πŸ“


✨ RATIONALE ✨

None. (she didn't feel like explaining herself and honestly? valid.)


✨ FUTURE DIRECTIONS ✨

None. the future holds nothing for tsort except more sorting. 🌈


✨ SEE ALSO ✨

  • the Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables

okay legal moment, don't scroll past this one:

portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .

🫢 reminder bestie: the Linux implementation of this interface may differ from POSIX, so always check the Linux manual page too. no cap.

mwah, that's the whole page!! this little gem came to you courtesy of IEEE/The Open Group, 2017, and that's the TSORT(1P) energy. go order something topologically, you've got this πŸ’œπŸ§šβ­

πŸ“¦ where this page comes from