+ -
当前位置:首页 → 问答吧 → 问个入门问题

问个入门问题

时间:2011-07-24

来源:互联网

# part of the file ~/.bashrc

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

其中. ~/.bash_aliases的第1个小数点是什么意思

作者: anth   发布时间: 2011-07-24

执行脚本的一种方法

作者: dreamcast_sh   发布时间: 2011-07-24

引用:
. ~/.bash_aliases
这一句,如果不加.将启动一个子shell解释并执行.bash_aliases文件,加了.就在当前shell解释并执行.bash_aliases(准确地说,是在当前shell进程中从文件读取并执行其中的命令并获取返回值)。

作者: levee   发布时间: 2011-07-24

levee 写道:
引用:
. ~/.bash_aliases
这一句,如果不加.将启动一个子shell解释并执行.bash_aliases文件,加了.就在当前shell解释并执行.bash_aliases。

谢谢

作者: anth   发布时间: 2011-07-24

man dash
引用:
. file
The commands in the specified file are read and executed by the shell.

man bash
引用:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environ‐
ment 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 shopt 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.

man zshbuiltins
引用:
. file [ arg ... ]
Read commands from file and execute them in the current shell envi‐
ronment.

If file does not contain a slash, or if PATH_DIRS is set, the shell
looks in the components of $path to find the directory containing
file. Files in the current directory are not read unless `.' appears
somewhere in $path. If a file named `file.zwc' is found, is newer
than file, and is the compiled form (created with the zcompile
builtin) of file, then commands are read from that file instead of
file.

If any arguments arg are given, they become the positional parame‐
ters; the old positional parameters are restored when the file is
done executing. The exit status is the exit status of the last com‐
mand executed.

作者: ChenFengyuan   发布时间: 2011-07-24

具体用途是不加点的话,子进程对变量的所有变动在父进程中不起效。

所以一般牵扯到变量共享的

贴别是调用设置变量参数的自脚本

必须前头带点

作者: jarlyyn   发布时间: 2011-07-24

当我们编辑完一个脚本文件后希望其立即生效。
方法一: 重启shell
方法二: 重启系统
方法三: $ . ./xxx.sh 或者 $ source ./xxx.sh

. 与 source 等价.

作者: taiandotzhang   发布时间: 2011-07-24