After setup, replace the script shell with server.
Do not return to the shell after server exits.
Which statement is appropriate?
exec COMMAND replaces the current shell process with COMMAND; later shell statements are not run if exec succeeds.
Detailed explanation
exec serverCorrect. exec replaces the current shell with server without leaving a child shell.
server &Incorrect. server & starts a background child while the original shell continues.
source serverIncorrect. source attempts to read server as shell source, not replace the process.
export serverIncorrect. export marks a variable for inheritance and does not run the command.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --norc -c 'exec printf replaced; printf not-run'Expected result
replacedだけを表示Key points
- Replace current process
- No return on success
- PID is retained
Notes
- Environment: GNU Bash 5.2 / 短命シェル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.