Era*_*dir 3 linux bash shell executable
在shell中,有什么区别?
. executable
Run Code Online (Sandbox Code Playgroud)
和
./executable
Run Code Online (Sandbox Code Playgroud)
在第一个中,点是一个快捷方式source吧?那么./executable和之间有区别source executable吗?
./executable运行当前工作目录中的可执行文件.(executable如果.你没有$PATH,通常没有),这是不够的.在这种情况下,executable可以是一个精灵二进制文件,或者一个开头的脚本#!/some/interpreter,或者你可以做的任何东西exec(在Linux上它可能是一切,多亏了binfmt模块).
. executable将shell脚本提供到当前shell中,无论它是否具有执行权限.没有创建新进程.在bash,根据$PATH变量搜索脚本.脚本可以设置将在保持设置环境变量的外壳,定义函数和别名等.