diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-08-10 17:28:47 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-08-11 09:34:45 +0200 |
commit | 89bf86e0157316a44457fb955c6d3deeb02e9802 (patch) | |
tree | 4602bf4a1ea8ff1ffc6e47be83c402169fb5f170 | |
parent | 0337b3d51c848edb3c0532f58416be3a87ae70b7 (diff) | |
download | systemd-89bf86e0157316a44457fb955c6d3deeb02e9802.tar.gz |
machinectl: allow --setenv=FOO
-rw-r--r-- | man/machinectl.xml | 18 | ||||
-rw-r--r-- | src/machine/machinectl.c | 10 |
2 files changed, 13 insertions, 15 deletions
diff --git a/man/machinectl.xml b/man/machinectl.xml index ad47b6102e..7ecb8885a2 100644 --- a/man/machinectl.xml +++ b/man/machinectl.xml @@ -712,14 +712,16 @@ </varlistentry> <varlistentry> - <term><option>-E <replaceable>NAME</replaceable>=<replaceable>VALUE</replaceable></option></term> - <term><option>--setenv=<replaceable>NAME</replaceable>=<replaceable>VALUE</replaceable></option></term> - - <listitem><para>When used with the <command>shell</command> command, sets an environment - variable to pass to the executed shell. Takes an environment variable name and value, - separated by <literal>=</literal>. This switch may be used multiple times to set multiple - environment variables. Note that this switch is not supported for the - <command>login</command> command (see below).</para></listitem> + <term><option>-E <replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term> + <term><option>--setenv=<replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term> + + <listitem><para>When used with the <command>shell</command> command, sets an environment variable for + the executed shell. This option may be used more than once to set multiple variables. When + <literal>=</literal> and <replaceable>VALUE</replaceable> are omitted, the value of the variable with + the same name in the program environment will be used.</para> + + <para>Note that this option is not supported for the <command>login</command> command. + </para></listitem> </varlistentry> <varlistentry> diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index b4c251078b..3f4ad87897 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -2510,7 +2510,7 @@ static int help(int argc, char *argv[], void *userdata) { " --kill-who=WHO Who to send signal to\n" " -s --signal=SIGNAL Which signal to send\n" " --uid=USER Specify user ID to invoke shell as\n" - " -E --setenv=VAR=VALUE Add an environment variable for shell\n" + " -E --setenv=VAR[=VALUE] Add an environment variable for shell\n" " --read-only Create read-only bind mount\n" " --mkdir Create directory before bind mounting, if missing\n" " -n --lines=INTEGER Number of journal entries to show\n" @@ -2765,13 +2765,9 @@ static int parse_argv(int argc, char *argv[]) { break; case 'E': - if (!env_assignment_is_valid(optarg)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Environment assignment invalid: %s", optarg); - - r = strv_extend(&arg_setenv, optarg); + r = strv_env_replace_strdup_passthrough(&arg_setenv, optarg); if (r < 0) - return log_oom(); + return log_error_errno(r, "Cannot assign environment variable %s: %m", optarg); break; case ARG_MAX_ADDRESSES: |