bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/20 18:39:26
bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.

bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.
bash builtin command exec 的man手册有一句不甚求解
If -a is supplied,the shell passes name as the zeroth argument to the executed command.
说不清楚给想关背景也可以,或是给个例子.

bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.
如果你在exec后添加-a选项,则该选项后面的name参数 将作为位置参数$0的值,本来$0的值为当前进程所对应的命令的名字.
我给你一例 对比之,以我的名字 ranpanf作为 -a的name参数.
ranpanf@ranpanf-laptop:~$ exec -a ranpanf bash
ranpanf@ranpanf-laptop:~$ echo $0
ranpanf
ranpanf@ranpanf-laptop:~$
看到了吗?
如果不加-a选项的话
ranpanf@ranpanf-laptop:~$ exec bash
ranpanf@ranpanf-laptop:~$ echo $0
bash
ranpanf@ranpanf-laptop:~$
这就是区别