Why you should use “exec” in all your wrapper shell scripts
github.com
github.com
> - The exit code of the wrapper will automatically become the exit code of wrapped_tool. Of course, you can achieve the same effect if you use set -e in the shell script.
False. Exit code of the last executed command is the exit code of the whole script.
> - While running, only the wrapped_tool is in memory, the shell is wiped out on exec and no longer uses any resources (memory, process scheduling, ...)
True.
> - The process name and path is wrapped_tool, not the shell script.
True, but it's not always a benefit (from my experience, when it actually matters it's usually a drawback).
> - If the wrapper is supervised and the caller decides to kill it, it will kill directly the wrapped_tool. Otherwise, it would only kill the shell and wrapped_tool might continue to run in the background.
This is true only for broken supervisors. Supervised process should be put in a process group, so supervisor can send a signal to the whole process group.