chiark / gitweb /
acticate: rename --environment to --setenv
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 29 Dec 2013 19:56:09 +0000 (14:56 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 30 Dec 2013 05:17:15 +0000 (00:17 -0500)
Nspawn has --setenv, and systemd itself accepts systemd.setenv.
It is nice to have the same parameter name everywhere.

Old name is accepted, but not advertised.

man/systemd-activate.xml
src/activate/activate.c

index d48774d..35eec19 100644 (file)
@@ -119,7 +119,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
       <varlistentry>
         <term><option>-E <replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term>
-        <term><option>--environment=<replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term>
+        <term><option>--setenv=<replaceable>VAR</replaceable><optional>=<replaceable>VALUE</replaceable></optional></option></term>
 
         <listitem><para>Add this variable to the environment of the
         launched process. If <replaceable>VAR</replaceable> is
index cf545d6..23c484c 100644 (file)
@@ -38,7 +38,7 @@
 static char** arg_listen = NULL;
 static bool arg_accept = false;
 static char** arg_args = NULL;
-static char** arg_environ = NULL;
+static char** arg_setenv = NULL;
 
 static int add_epoll(int epoll_fd, int fd) {
         struct epoll_event ev = {
@@ -162,14 +162,14 @@ static int launch(char* name, char **argv, char **env, int fds) {
         char **s;
         unsigned i;
 
-        length = strv_length(arg_environ);
+        length = strv_length(arg_setenv);
 
         /* PATH, TERM, HOME, USER, LISTEN_FDS, LISTEN_PID, NULL */
         envp = new0(char *, length + 7);
         if (!envp)
                 return log_oom();
 
-        STRV_FOREACH(s, arg_environ) {
+        STRV_FOREACH(s, arg_setenv) {
                 if (strchr(*s, '='))
                         envp[n_env++] = *s;
                 else {
@@ -302,12 +302,11 @@ static int help(void) {
         printf("%s [OPTIONS...]\n\n"
                "Listen on sockets and launch child on connection.\n\n"
                "Options:\n"
-               "  -l --listen=ADDR     Listen for raw connections at ADDR\n"
-               "  -a --accept          Spawn separate child for each connection\n"
-               "  -h --help            Show this help and exit\n"
-               "  -E --environment=NAME[=VALUE]\n"
-               "                       Pass an environment variable to children\n"
-               "  --version            Print version string and exit\n"
+               "  -l --listen=ADDR         Listen for raw connections at ADDR\n"
+               "  -a --accept              Spawn separate child for each connection\n"
+               "  -h --help                Show this help and exit\n"
+               "  -E --setenv=NAME[=VALUE] Pass an environment variable to children\n"
+               "  --version                Print version string and exit\n"
                "\n"
                "Note: file descriptors from sd_listen_fds() will be passed through.\n"
                , program_invocation_short_name
@@ -322,11 +321,12 @@ static int parse_argv(int argc, char *argv[]) {
         };
 
         static const struct option options[] = {
-                { "help",         no_argument,       NULL, 'h'           },
-                { "version",      no_argument,       NULL, ARG_VERSION   },
-                { "listen",       required_argument, NULL, 'l'           },
-                { "accept",       no_argument,       NULL, 'a'           },
-                { "environment",  required_argument, NULL, 'E'           },
+                { "help",        no_argument,       NULL, 'h'           },
+                { "version",     no_argument,       NULL, ARG_VERSION   },
+                { "listen",      required_argument, NULL, 'l'           },
+                { "accept",      no_argument,       NULL, 'a'           },
+                { "setenv",      required_argument, NULL, 'E'           },
+                { "environment", required_argument, NULL, 'E'           }, /* alias */
                 {}
         };
 
@@ -358,7 +358,7 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case 'E': {
-                        int r = strv_extend(&arg_environ, optarg);
+                        int r = strv_extend(&arg_setenv, optarg);
                         if (r < 0)
                                 return r;