DOT(1POSIX)

πŸ‘‘ dot β€” execute commands in the current environment πŸ’…

okay bestie, so this is the DOT(1POSIX) page from the POSIX Programmer's Manual and we're gonna get into it, because . (yes, just a lil dot, that's the whole command name) is lowkey one of the most iconic shell built-ins and you NEED to know her.


🌸 PROLOG 🌸

okay so first things first, this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, consult the corresponding Linux manual page for the details of Linux behavior, fr), or honestly the interface may just not be implemented on Linux at all. it's giving "check ur own system, babe."


✨ NAME ✨

dot β€” execute commands in the current environment πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€



. file

πŸ’– DESCRIPTION πŸ’–

the shell shall execute commands from the file in the current environment. that's the whole vibe. no subshell, no escape hatch, she's running IN ur environment. periodt.

if file does not contain a <slash>, the shell shall use the search path specified by PATH to find the directory containing file. but here's the plot twist bestie β€” unlike normal command search, the file searched for by the dot utility need not be executable. wild, right? she doesn't need the +x glow-up to get picked.

if no readable file is found, a non-interactive shell shall abort. an interactive shell shall write a diagnostic message to standard error, but this condition shall not be considered a syntax error. so like, it's a whole crisis but not THAT kind of crisis.


🌈 OPTIONS 🌈

None. literally none. she's serving minimalism. 🧚


🌟 OPERANDS 🌟

See the DESCRIPTION. (that's where the file tea is, go look πŸ‘€)


πŸ’œ STDIN πŸ’œ

Not used. she's not listening to ur keyboard input, sorry.


πŸ“ INPUT FILES πŸ“

See the DESCRIPTION.


πŸ”₯ ENVIRONMENT VARIABLES πŸ”₯

See the DESCRIPTION.


⭐ ASYNCHRONOUS EVENTS ⭐

Default. nothing spicy happening here.


🫢 STDOUT 🫢

Not used. she's not writing anything to standard output herself.


😭 STDERR 😭

The standard error shall be used only for diagnostic messages. that's her venting channel and that's it.


πŸ¦‹ OUTPUT FILES πŸ¦‹

None. she creates nothing, she just runs.


πŸ‘‘ EXTENDED DESCRIPTION πŸ‘‘

None. no extra lore, no bonus content.


πŸ’€ EXIT STATUS πŸ’€

okay listen up because this one's got layers:

  • if no readable file was found, or if the commands in the file could not be parsed, and the shell is interactive (and therefore does not abort; see Section 2.8.1, Consequences of Shell Errors), the exit status shall be non-zero.
  • Otherwise, return the value of the last command executed, or a zero exit status if no command is executed.

so basically: "did the last thing work? cool, that's ur answer. did everything explode and you're still at a prompt? non-zero, bestie."


🌸 CONSEQUENCES OF ERRORS 🌸

Default.

The following sections are informative.


πŸŽ€ APPLICATION USAGE πŸŽ€

None. nothing extra to add, she speaks for herself.


✨ EXAMPLES ✨

okay this example EATS, look:



cat foobar
foo=hello bar=world
. ./foobar
echo $foo $bar
hello world

see how the variables from foobar stuck around after the dot? that's the whole point of sourcing. main character behavior only. πŸ”₯


πŸ’… RATIONALE πŸ’…

so some older implementations searched the current directory for the file, even if the value of PATH disallowed it. this behavior was omitted from this volume of POSIX.1‐2017 due to concerns about introducing the susceptibility to trojan horses that the user might be trying to avoid by leaving dot out of PATH. πŸ’€ yeah. security girlies stay winning.

also, the KornShell version of dot takes optional arguments that are set to the positional parameters. this is a valid extension that allows a dot script to behave identically to a function. cute, right? just know that's an extension, not the base POSIX behavior, iykyk.


🧚 FUTURE DIRECTIONS 🧚

None. the future is bright and unchanged.


🌈 SEE ALSO 🌈

  • Section 2.14, Special Built-In Utilities
  • return

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 .


okay that's the whole page bestie, go source something responsibly 🫢

IEEE/The Open Group β€” 2017 β€” DOT(1POSIX) πŸ’…βœ¨ that's the sign-off, that's the footer, we ate, no crumbs. πŸŽ€

πŸ“¦ where this page comes from