source是csh(C Shell)的内置命令:
标识读入并执行文件中的命令.
这与执行shell脚本是不一样的./script.sh会启动一个新的shell并执行script.sh中的命令.
source [-h] name [args ...]
The shell reads and executes commands from name. The commands
are not placed on the history list. If any args are given,
they are placed in argv. (+) source commands may be nested; if
they are nested too deeply the shell may run out of file
descriptors. An error in a source at any level terminates all
nested source commands. With -h, commands are placed on the
history list instead of being executed, much like `history -L'.
=========================
sh (Bourne Shell)和ksh (Korn Shell)有一个类似的命令 . (点dot)
. file The commands in the specified file are read and executed by the
shell. The return command may be used to return to the . com-
mand's caller. If file contains any ``/'' characters, it is used
as is. Otherwise, the shell searches the PATH for the file. If
it is not found in the PATH, it is sought in the current working
directory.
========================
bash (GNU Bourne-Again Shell)是组合了sh/ksh/csh的特征同时支持(source)命令和(.)命令
source in shell
最新推荐文章于 2022-11-11 21:50:53 发布