这个 bash 运算符是做什么的? (斜线点)

What does this bash operator do? (slash dot)

\. <name of a script> 在 bash 中做什么?

我在这个上下文中找到它:

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

我试着搜索它我总是很难搜索符号。

. 来源另一个文件。您可以搜索“shell 中的点命令”并阅读例如 posix 文档 https://pubs.opengroup.org/onlinepubs/009695399/utilities/dot.html .

\<some_command> 运行没有别名的命令。你可能会喜欢:

alias .=cat

然后 . file 将 cat 文件,但 \. file 仍将获取文件。

它引用了前面的字符,因此不能以其他方式对其进行操作。在上述情况下,我很惊讶它在那里,因为通常是单个 '.'。在功能上将是“运行 我本地环境中的那个文件”——另一个名称将是“source”它,这是 CSH 类似命令的名称。 '' 可能会保护它免受@kamilcuk 所说的安全问题的影响。

echo echo hi > foo.sh

[ -s foo.sh ] && . foo.sh
hi

[ -s foo.sh ] && \. foo.sh
hi