LinuxForum.Fans
Тема

зачем в башовских скриптах exec

Автор: vux 5 сообщений 806 просмотров
#295812

Вот например .xinitrc.
В этом файле у меня запускается весь бекграундный софт (parcellite, dropbox, setxkbmap, feh...) и в последней строчке собственно запуск виндов-менеджера.
Недавно увидел на лоре конфиг одного человека. Там у него все команды запускаються примерным образом:

text
setxkbmap ... &
feh ... &
dropbox &
exec xinit

Вопрос:
Зачем в последней строчке exec, а в предыдущих его нет. Раньше думал что без разницы и ее как бы невидно. Но все же хотелось бы объяснений.

#295816
man 1 bash написал:
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If
the -l option is supplied, the shell places a dash at the beginning of the zeroth argument passed to command. This is what
login(1) does. The -c option causes command to be executed with an empty environment. If -a is supplied, the shell passes
name as the zeroth argument to the executed command. If command cannot be executed for some reason, a non-interactive shell
exits, unless the shell option execfail is enabled, in which case it returns failure. An interactive shell returns failure if
the file cannot be executed. If command is not specified, any redirections take effect in the current shell, and the return
status is 0. If there is a redirection error, the return status is 1.

#295821

То есть в скриптах такого плана - где последняя программа должна остаться запущеной - команда exec заменяет собой bash который запускает этот скрипт?
Я правильно понимаю? Поправьте если туплю.

#295827
"vux" написал:
Я правильно понимаю?

Если я сам правильно понимаю, то да.

#295833

да так и есть. По процессам в памяти видно что с exec на один sh меньше. Спасибо.

Войдите или зарегистрируйтесь, чтобы ответить.