whats the difference between executing script like
# ./test
and
# . ./test
test is simple script for example
#!/bin/bash
export OWNER_NAME="ANGEL 12"
export ALIAS="angelique"
i know the results but im unsure what actually happens
Thanks
whats the difference between executing script like
# ./test
and
# . ./test
test is simple script for example
#!/bin/bash
export OWNER_NAME="ANGEL 12"
export ALIAS="angelique"
i know the results but im unsure what actually happens
Thanks
./foo如果它被标记为可执行foo并且具有正确的 shebang 行(或者是 ELF 二进制文件),则执行。它将在新进程中执行。
. ./foo或. foo在当前shell 中加载脚本。它等于source foo
对于您的示例代码,如果您希望导出的变量在您的 shell 中可用,则需要使用第二种方式。
仅使用点,bash 正在“采购”指定的文件。它等效于source内置并尝试在同一 shell 进程中包含和执行脚本。
启动一个新进程,当前的./shell 进程等待它终止。
第一个暗示脚本(或二进制文件)是可执行的。脚本(可能)包含一个 shebang 行,告诉使用哪个解释器。
第二个是“将 [argument] 作为 shell 脚本执行”的简写。作为参数传递的文件不需要设置可执行位。