本文介绍了命令“源"有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道命令 source
做什么.我已经尝试过:
I would like to know what does the command source
do. I have tried:
- 什么
$ whatis source
source: nothing appropriate.
- man
$ man source
No manual entry for source
- 来源(-h,-help等...)
$ source
source: not enough arguments
但是似乎没有关于它的文档.
But it seems no documentation about it.
我通常使用它来保存我的点文件中的所有更改,但是它究竟能做什么?为什么没有关于它的文档?
I commonly use it to save any changed on my dotfiles, but what does it exactly do? Why there is not documentation about it?
推荐答案
源
是bash shell内置命令,该命令执行作为参数传递的文件的内容, 在当前shell中 .它在.
(句号)中有一个同义词.
source
is a bash shell built-in command that executes the content of the file passed as an argument, in the current shell. It has a synonym in .
(period).
. filename [arguments]
source 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. If
filename does not contain a slash, file names in PATH are used to find the
directory containing filename. The file searched for in PATH need not be
executable. When bash is not in posix mode, the current directory is
searched if no file is found in PATH. If the sourcepath option to the short
builtin command is turned off, the PATH is not searched. If any arguments
are supplied, they become the positional parameters when filename is
executed. Otherwise the positional parameters are unchanged. The return
status is the status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or cannot be
read.
小心! ./
和 source
不太相同.
-
./script
将脚本作为可执行文件运行,启动新shell 来运行 -
源脚本
在当前shell 环境中从文件名读取并执行命令
./script
runs the script as an executable file, launching a new shell to run itsource script
reads and executes commands from filename in the current shell environment
注意: ./script
不是.脚本
,但.脚本
== 源脚本
Note: ./script
is not . script
, but . script
== source script
这篇关于命令“源"有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!