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.说不清楚给想关背景也可以,或是给个例子.
xSю@cY`֒В a]Z*lDW(V7Z6kbi g($:wι{OhTܪiVMJ^'z}ZdHqâ6yp/:釷w Of2 FR0Ui`Ӥ&N ٰT {:-k٫e^~]xtăqK,Kv$lWOm(X?EK^&g.wq1q̖aIRr<Ay8dsW3IpK& dJĚјPlyVø0' =.6 ˺&c '-88k@\OMDгGr5مc@S` VI>U

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:~$
这就是区别