来自 zshbuiltins 手册,
exec [ -cl ] [ -a argv0 ] simple command Replace the current shell with an external command rather than forking. With -c clear the environment; with -l prepend - to the argv[0] string of the command executed (to simulate a login shell); with -a argv0 set the argv[0] string of the command executed. See the section `Precommand Modifiers'.
我尝试使用-a
一个简单的脚本,但它似乎不起作用
[balakrishnan@mylap scripts]$ cat printer.sh;echo "-----";cat wrapper.sh
#!/bin/sh
echo $0 $1 $2 $3 $4
-----
#!/bin/zsh
argv0="$0"
exec -a "$argv0" printer.sh
[balakrishnan@mylap scripts]$ wrapper.sh
printer.sh
[balakrishnan@mylap scripts]$
由于我设置wrapper.sh
为argv0
,我希望在printer.sh
echos时打印它$0
。但它仍然打印printer.sh
。