bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/27 16:44:57
![bash builtin command exec 的man手册有一句不甚求解If -a is supplied,the shell passes name as the zeroth argument to the executed command.说不清楚给想关背景也可以,或是给个例子.](/uploads/image/z/14627735-71-5.jpg?t=bash+builtin+command+exec+%E7%9A%84man%E6%89%8B%E5%86%8C%E6%9C%89%E4%B8%80%E5%8F%A5%E4%B8%8D%E7%94%9A%E6%B1%82%E8%A7%A3If+-a+is+supplied%2Cthe+shell+passes+name+as+the+zeroth+argument+to+the+executed+command.%E8%AF%B4%E4%B8%8D%E6%B8%85%E6%A5%9A%E7%BB%99%E6%83%B3%E5%85%B3%E8%83%8C%E6%99%AF%E4%B9%9F%E5%8F%AF%E4%BB%A5%2C%E6%88%96%E6%98%AF%E7%BB%99%E4%B8%AA%E4%BE%8B%E5%AD%90.)
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:~$
这就是区别