Hide Forgot
Hello. Currently the variables defined in the environment files can be passed to the Exec*= commands in two ways. ${FOOBAR} ... expanding the variable into one word $FOOBAR ... splitting the variable into multiple words (space separated) Hovever, there's no way, how to omit leading switches when the value is not defined. Some daemons (like sensord) pass the variables like this: ExecStart=/usr/sbin/sensord -i $INTERVAL -l $LOG_INTERVAL -t $RRD_INTERVAL -r $RRD_LOGFILE -f daemon ...and as the daemon doesn't accept empty values, it cannot work when some of the variables are not defined or commented out. There should be a way how to conditionally omit the leading switches when the variable is not defined in the environment file. I would suggest the following or similar syntax for achieving that: $[FOOBAR|-o ] $[FOOBAR|--long-option=] The expressions would be substituted with the following forms only if the FOOBAR is defined in the EnvironmentFile: -o ${FOOBAR} --long-option=${FOOBAR} If the variable is not defined, then the whole expression would be ignored. This would make our lives easier ... writing wrapper scripts is not very convenient. Please, let me know if you find that achievable. Thank you. Regards, Jaromir.
Note: It doesn't necessarily need to be square brackets ... as the pipe character is not allowed in the variable names, it can be ${FOOBAR|--switch=} as well. I'm unsure how the escaping exactly works in this case. Guess you know the code better.
I am sorry, but I am not convinced we should invent another shell. Please either use the shell for this, or improve sensord to read a proper configuration file. systemd is explicitly not supposed to be a generic way how to add configuration files to daemons which don't support this. Sorry.