Bug 1006981 - [RFE] Conditional pairing of switches and variables (when the variable is defined in the environment file)
Summary: [RFE] Conditional pairing of switches and variables (when the variable is def...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 949521
TreeView+ depends on / blocked
 
Reported: 2013-09-11 15:57 UTC by Jaromír Cápík
Modified: 2016-02-01 01:59 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-12 19:09:07 UTC
Type: Bug


Attachments (Terms of Use)

Description Jaromír Cápík 2013-09-11 15:57:33 UTC
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.

Comment 1 Jaromír Cápík 2013-09-11 16:08:05 UTC
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.

Comment 2 Lennart Poettering 2013-09-12 19:09:07 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.