HASH(1POSIX)

๐ŸŒธ HASH(1POSIX) โ€” the POSIX Programmer's Manual, bestie edition ๐ŸŒธ

okay so before we even get into it, a lil heads-up from the manual itself:

๐Ÿ“ข PROLOG

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details on Linux behavior), or the interface may not even be implemented on Linux at all. ๐Ÿ’€ so like, vibe check your platform first, bestie.


โœจ NAME โœจ

hash โ€” remember or report utility locations ๐Ÿง โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

hash [utility...]

hash -r

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so the hash utility is gonna affect the way the current shell environment remembers where utilities were found, exactly as described in Section 2.9.1.1, Command Search and Execution. Depending on what arguments you hand it, it's either adding utility locations to its list of remembered locations, or it's straight-up purging the whole list. ๐Ÿงน

And when you give it no arguments at all? It reports on the contents of the list. Like, "here's what I remember, queen." ๐Ÿ‘‘

๐Ÿšจ important: utilities that are provided as built-ins to the shell shall not be reported by hash. They're built in, they don't need a lil address book entry, iykyk.

โœจ OPTIONS โœจ

The hash utility shall conform to the Base Definitions volume of POSIX.1โ€2017, Section 12.2, Utility Syntax Guidelines. slay, standards.

The following option shall be supported:

  • -r โ€” forget all previously remembered utility locations. memory? wiped. ๐Ÿงฝ it's giving factory reset.

๐Ÿฆ‹ 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. โš ๏ธ but if utility contains one or more <slash> characters, the results are unspecified. like, we don't know her, we can't speak on her. ๐Ÿ™ˆ

๐ŸŒˆ STDIN ๐ŸŒˆ

Not used. she doesn't read. ๐Ÿ’…


๐Ÿ“ INPUT FILES ๐Ÿ“

None. nothing coming in.


๐ŸŒ ENVIRONMENT VARIABLES ๐ŸŒ

The following environment variables shall affect the execution of hash:

  • 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, override the values of all the other internationalization variables. she's the main character, periodt.
  • 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).
  • 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.
  • PATH โ€” determines the location of utility, as described in the Base Definitions volume of POSIX.1โ€2017, Chapter 8, Environment Variables.

โšก ASYNCHRONOUS EVENTS โšก

Default. nothing special happening here.


๐Ÿ’ฌ 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. ๐Ÿ“

That list shall consist of those utilities named in previous hash invocations that have been invoked, and may contain those invoked and found through the normal command search process. so like, it's a mix, bestie.


๐Ÿ˜ญ STDERR ๐Ÿ˜ญ

The standard error shall be used only for diagnostic messages. that's its whole job.


๐Ÿ“‚ OUTPUT FILES ๐Ÿ“‚

None. we're not writing files here.


๐Ÿงš EXTENDED DESCRIPTION ๐Ÿงš

None. there is no extended description. she said what she said. โœ‹


๐Ÿ”ฅ EXIT STATUS ๐Ÿ”ฅ

The following exit values shall be returned:

  • 0 โ€” successful completion. ate. ๐Ÿ’…
  • >0 โ€” an error occurred. ๐Ÿ˜ญ something went wrong.

๐Ÿ’€ CONSEQUENCES OF ERRORS ๐Ÿ’€

Default.

The following sections are informative. (translation: the tea below is context, not requirements, bestie ๐Ÿซ–)


๐Ÿซถ APPLICATION USAGE ๐Ÿซถ

Since hash affects the current shell execution environment, it is always provided as a shell regular built-in. ๐Ÿ  so if you call it in a separate utility execution environment โ€” like one of these:

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

โ€ฆthen it does not affect the command search process of the caller's environment. like, you did all that in a whole different room and nobody in the group chat heard it. ๐Ÿ™ˆ

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. sneaky.

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"

like, iconic little trick. ๐Ÿช„

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 anyway. so like, don't stress. ๐Ÿ’†


๐Ÿ“ EXAMPLES ๐Ÿ“

None. no examples in the source, so no examples from me. we stay honest. โœจ


๐Ÿง  RATIONALE ๐Ÿง 

None. the reasoning is a mystery even to me. ๐Ÿ’€


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None. the future is unwritten, bestie. ๐Ÿฆ‹


๐Ÿ‘€ 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. 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 one's brought to you by IEEE/The Open Group, 2017 โ€” HASH(1POSIX), that's the manual page we just devoured, and yes she is iconic. go forth and hash -r responsibly. mwah. ๐Ÿ’–โœจ๐Ÿฆ‹๐Ÿ‘‘
๐Ÿ“ฆ where this page comes from