调用我的 bash 脚本而不是使用 Source 命令的简短方法

Yur*_*j73 2 bash shell-script

我的脚本使用并修改了一个 shell 变量。我需要始终使用:

source myscript
Run Code Online (Sandbox Code Playgroud)

有没有更短的方法来调用这个脚本并让它修改当前 shell 的环境?

可以通过使用本答案中描述的函数 use 优雅地完成它,但我需要一种更快的方法。

Mic*_*zek 5

您可以将.其用作source. 从bash(1)手册页:

.  filename [arguments]
source filename [arguments]

Read and execute commands from filename in the current shell environment and return
the exit status of the last command executed from filename.
Run Code Online (Sandbox Code Playgroud)