Pass bash script parameters to sub-process unchanged Pass bash script parameters to sub-process unchanged bash bash

Pass bash script parameters to sub-process unchanged


When a shell script wraps around an executable, and if you do not want to do anything after the executable completes (that's a common case for wrapper scripts, in my experience), the correct way to call the executable is:

exec /the/exe "$@"

The exec built-in tells the shell to just give control to the executable without forking.

Practically, that prevents a useless shell process from hanging around in the system until the wrapped process terminates.

That also means that no command can be executed after the exec command.


You have to put the $@ in quotes:

/the/exe "$@"