Есть ли способ, которым я могу выполнить приложение из сценария оболочки, но не создать другой процесс. Я хочу, чтобы это выглядело только как один процесс . Не имеет значения, будет ли мой сценарий оболочки заменен новым процессом или он продолжится после завершения вызываемого приложения.
Это также должно решить мой предыдущий вопрос: 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.
Пример:
user@host:~$ PS1="supershell$ "
supershell$ bash
user@host:~$ PS1="subshell$ "
subshell$ exec echo hello
hello
supershell$
Как видите, подоболочка заменена на echo
.