From: Zbigniew Jędrzejewski-Szmek Date: Tue, 10 Aug 2021 15:25:47 +0000 (+0200) Subject: run: allow --setenv=FOO X-Git-Tag: v250-rc1~842^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0337b3d51c848edb3c0532f58416be3a87ae70b7;p=thirdparty%2Fsystemd.git run: allow --setenv=FOO --- diff --git a/man/systemd-run.xml b/man/systemd-run.xml index fc8716ea79d..99726dabfbb 100644 --- a/man/systemd-run.xml +++ b/man/systemd-run.xml @@ -239,11 +239,15 @@ - - + + - Runs the service process with the specified environment variable set. - Also see Environment= in + Runs the service process with the specified environment variable set. This parameter + may be used more than once to set multiple variables. When = and + VALUE are omitted, the value of the variable with the same name in the + program environment will be used. + + Also see Environment= in systemd.exec5. diff --git a/src/run/run.c b/src/run/run.c index 993f1bc4f44..fb385712281 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -111,7 +111,7 @@ static int help(void) { " --nice=NICE Nice level\n" " --working-directory=PATH Set working directory\n" " -d --same-dir Inherit working directory from caller\n" - " -E --setenv=NAME=VALUE Set environment\n" + " -E --setenv=NAME[=VALUE] Set environment variable\n" " -t --pty Run service on pseudo TTY as STDIN/STDOUT/\n" " STDERR\n" " -P --pipe Pass STDIN/STDOUT/STDERR directly to service\n" @@ -322,8 +322,9 @@ static int parse_argv(int argc, char *argv[]) { break; case 'E': - if (strv_extend(&arg_environment, optarg) < 0) - return log_oom(); + r = strv_env_replace_strdup_passthrough(&arg_environment, optarg); + if (r < 0) + return log_error_errno(r, "Cannot assign environment variable %s: %m", optarg); break;