zub*_*out 13 bash programming process
有没有办法可以从 shell 脚本执行应用程序,但不能创建另一个进程。我希望它看起来像一个进程。我的 shell 脚本是否被新进程替换或者在被调用的应用程序结束后它是否会继续都无关紧要。
这也应该解决我之前的问题:https
: //askubuntu.com/questions/247632/is-there-a-way-to-associate-additional-application-launcher-with-an-app
非常感谢您的帮助.
您可以使用以下exec命令:
$ help exec
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
Replace the shell with the given command.
Execute COMMAND, replacing this shell with the specified program.
ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
any redirections take effect in the current shell.
Options:
-a name pass NAME as the zeroth argument to COMMAND
-c execute COMMAND with an empty environment
-l place a dash in the zeroth argument to COMMAND
If the command cannot be executed, a non-interactive shell exits, unless
the shell option `execfail' is set.
Exit Status:
Returns success unless COMMAND is not found or a redirection error occurs.
Run Code Online (Sandbox Code Playgroud)
例子:
user@host:~$ PS1="supershell$ "
supershell$ bash
user@host:~$ PS1="subshell$ "
subshell$ exec echo hello
hello
supershell$
Run Code Online (Sandbox Code Playgroud)
如您所见,子外壳被替换为echo.
| 归档时间: |
|
| 查看次数: |
23306 次 |
| 最近记录: |