HASH(1P)

πŸ’– HASH(1P) β€” the POSIX Programmer's Manual page, but make it make sense πŸ’–

okay bestie, welcome to HASH(1P), straight outta the POSIX Programmer's Manual. pull up a chair, grab a boba, we're learning about the little shell helper that remembers where your utilities live so you don't have to 🫢


✨ PROLOG ✨

okay so real talk first, no cap: 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 deets on Linux behavior β€” or honestly the interface might not even be implemented on Linux at all. it's giving "your mileage may vary" πŸ’€


πŸŽ€ NAME πŸŽ€

hash β€” remember or report utility locations


🌸 SYNOPSIS 🌸

hash [utility...]

hash -r

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: the hash utility shall affect the way the current shell environment remembers the locations of utilities found, as described in Section 2.9.1.1, Command Search and Execution.

depending on the arguments you hand it, it shall either:

  • add utility locations to its list of remembered locations, or
  • purge the contents of the list.

and when you pass no arguments at all? it shall report on the contents of the list. main character energy: it just tells you what it knows πŸ‘‘

lowkey important: utilities provided as built-ins to the shell shall not be reported by hash. built-ins stay unbothered, unlisted, iconic ✨

πŸ’… OPTIONS πŸ’…

the hash utility shall conform to the Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.

the following option shall be supported:

  • -r β€” forget all previously remembered utility locations. it's giving selective memory loss, on purpose, for the plot 🧚

πŸ“ OPERANDS πŸ“

the following operand shall be supported:

  • utility β€” the name of a utility to be searched for and added to the list of remembered locations. ⚠️ if utility contains one or more <slash> characters, the results are unspecified. that's the "we don't know her" zone, bestie, don't go there πŸ™ˆ

⭐ STDIN ⭐

not used. she doesn't read, she only remembers πŸ’…


🌈 INPUT FILES 🌈

none.


πŸ’œ ENVIRONMENT VARIABLES πŸ’œ

the following environment variables shall affect the execution of hash:

  • LANG β€” provide 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, override the values of all the other internationalization variables. she's the final boss of locale settings πŸ‘‘
  • LC_CTYPE β€” determine 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).
  • LC_MESSAGES β€” determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
  • NLSPATH β€” determine the location of message catalogs for the processing of LC_MESSAGES.
  • PATH β€” determine the location of utility, as described in the Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables.

πŸ”₯ ASYNCHRONOUS EVENTS πŸ”₯

default. nothing extra, nothing spicy, just default 🫢


🧚 STDOUT 🧚

the standard output of hash shall be used when no arguments are specified.

its format is unspecified, but it includes the pathname of each utility in the list of remembered locations for the current shell environment.

this list shall consist of:

  • those utilities named in previous hash invocations that have been invoked, and
  • it may contain those invoked and found through the normal command search process.

so like, sometimes she remembers the ones you told her about, and sometimes she also remembers the ones she found on her own. she contains multitudes πŸ’–


🌸 STDERR 🌸

the standard error shall be used only for diagnostic messages. no casual chatting on stderr, that's not what it's for, periodt ✨


πŸŽ€ OUTPUT FILES πŸŽ€

none.


πŸ’– EXTENDED DESCRIPTION πŸ’–

none. (she said "that's it, that's the whole thing") πŸ’…


⭐ EXIT STATUS ⭐

the following exit values shall be returned:

  • 0 β€” successful completion. slay πŸŽ‰
  • >0 β€” an error occurred. not slay 😭

πŸ¦‹ CONSEQUENCES OF ERRORS πŸ¦‹

default.

heads up bestie: the following sections are informative. they're lore, not law πŸ“–

πŸ’… APPLICATION USAGE πŸ’…

since hash affects the current shell execution environment, it is always provided as a shell regular built-in. periodt.

if it is called in a separate utility execution environment, such as one of the following:

nohup hash -r
find . -type f | xargs hash

then it does not affect the command search process of the caller's environment. it's giving "she's in her own little world and the original shell didn't hear a thing" 😭

the hash utility may be implemented as an alias β€” for example, alias -t - β€” in which case utilities found through normal command search are not listed by the hash command.

the effects of hash -r can also be achieved portably by resetting the value of PATH; in the simplest form, this can be:

PATH="$PATH"

the use of hash with utility names is unnecessary for most applications, but may provide a performance improvement on a few implementations; normally, the hashing process is included by default. iykyk ✨


πŸ“ EXAMPLES πŸ“

none.


🌈 RATIONALE 🌈

none.


🧚 FUTURE DIRECTIONS 🧚

none.


πŸ’œ SEE ALSO πŸ’œ

  • Section 2.9.1.1, Command Search and Execution
  • The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines

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. (translation: the original is the one who decides, bestie, she holds the receipts 🧾)

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 .


and that's the whole page, bestie! πŸ’– this little cutie came to you from IEEE/The Open Group, dated 2017 β€” HASH(1P), forever and always. go remember some utility locations, you absolute icon 🫢✨

πŸ“¦ where this page comes from