I'd like to execute a statement to start a server. For that I have an environment variable to determine which server is to be started. I was given this command as a starting point:
eval "exec gunicorn --chdir /this/dir package.sub:call_main() -b 0.0.0.0:80"
As I have a few kinds of servers to start up, I would like to parameterise the script. And after searching around, I found out the quotations are redundant. So what I have now is:
APP=main
eval exec gunicorn --chdir /this/dir package.sub:call_${APP}() -b 0.0.0.0:80
This, however produces a syntax error near unexpected token '('. Ideally I would even like to have a default argument like ${APP:-main}, but I guess that is possible once the syntax error issue is resolved.
What is wrong with the statement above? Additionally, is eval or even exec needed here?
eval. And the error was indeed on the sub-shell parentheses. Reading up onexecit seems to be beneficial, as I'm using a container, so being the last command of a script it's natural to replace the shell with that process. – Felix Feb 05 '19 at 08:08gunicorn, then it makes sense to useexecthere. – Kusalananda Feb 05 '19 at 08:09