Score:-1

linux script: '. /path/to/anotherscript'

gl flag

I have a script file which refers to another script file(containing some functions) this way:

. "${scripts_dir}/update.sh"

What does it mean in linux scripting?

Does it load code in update.sh so that it can be invoked now onwards?

Raffa avatar
jp flag
"*Does it load code in update.sh so that it can be invoked now onwards?*" ... yes as if it's part of the calling script ... It's called sourcing ... It reads and executes the code in the sourced file in the current running shell vs. in a sub-shell if you run the script as an executable instead.
hr flag
... see also [What are the differences between executing shell scripts using "source file.sh", "./file.sh", "sh file.sh", ". ./file.sh"?](https://askubuntu.com/questions/601055/what-are-the-differences-between-executing-shell-scripts-using-source-file-sh)
terdon avatar
cn flag
Does this answer your question? [What are the differences between executing shell scripts using "source file.sh", "./file.sh", "sh file.sh", ". ./file.sh"?](https://askubuntu.com/questions/601055/what-are-the-differences-between-executing-shell-scripts-using-source-file-sh)
Score:3
cn flag
raj

. is a command (!) that sources the indicated script. Sourcing means executing the script, but in context of currently running shell. If you "normally" execute a script from another script, then a separate shell instance (called a subshell) is used to execute the second script.

This is used usually if you want to set some shell variables or environment variables, define functions or aliases etc. in the second script. In case of "normal" execution, they won't be passed back to the first script, but with sourcing it is possible.

Also an important difference occurs if the command exit is used in the second script. In case of "normal" execution, this ends the second script (to be precise, exits the shell that executes the second script, which obviously causes the script to terminate), but the first script continues to run from the next command after the call to second script. However if exit is used in a second script that is sourced, it ends both scripts at this point (because it exits the shell that is executing the first script).

raj avatar
cn flag
raj
Shell builtin are commands too; there are **internal commands**, aka shell builtins, and **external commands** which are separate executable files. You probably meant that `.` is not an **executable** but a shell builtin.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.