------------------------------------------------------------ revno: 1416 committer: James Hunt <[email protected]> branch nick: upstart-setenv+getenv timestamp: Wed 2013-01-09 11:13:03 +0000 message: * init/job_class.c: - job_class_environment_set(): - Comments. - Handle scenario where user specifies a variable without an equals. * util/initctl.c: - list_env_qsort_compar(): Renamed from list_env_strcmp_compar(). Now uses strcoll(3) for locale-awareness. * util/man/initctl.8: - Added details of 'get-env', 'set-env', 'unset-env', 'list-env' and 'reset-env'. - Tidied up 'usage' stanza section. modified: ChangeLog init/job_class.c util/initctl.c util/man/initctl.8
-- lp:upstart https://code.launchpad.net/~upstart-devel/upstart/trunk Your team Upstart Reviewers is subscribed to branch lp:upstart. To unsubscribe from this branch go to https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog' --- ChangeLog 2013-01-09 10:13:36 +0000 +++ ChangeLog 2013-01-09 11:13:03 +0000 @@ -1,10 +1,20 @@ -01-09 James Hunt <[email protected]> +2013-01-09 James Hunt <[email protected]> * init/man/init.5: - Overhauled 'Job environment' section. * util/initctl.c: - Added 'unset-env' and 'reset-env' commands. - Added missing periods in usage text. + - list_env_qsort_compar(): Renamed from list_env_strcmp_compar(). Now + uses strcoll(3) for locale-awareness. + * init/job_class.c: + - job_class_environment_set(): + - Comments. + - Handle scenario where user specifies a variable without an equals. + * util/man/initctl.8: + - Added details for 'get-env', 'set-env', 'unset-env', 'list-env' and + 'reset-env'. + - Tidied up 'usage' stanza section. 2013-01-08 James Hunt <[email protected]> === modified file 'init/job_class.c' --- init/job_class.c 2013-01-08 15:57:31 +0000 +++ init/job_class.c 2013-01-09 11:13:03 +0000 @@ -140,7 +140,7 @@ /** * job_class_environment_set: * - * @var: name[/value] pair of environment variable to set, + * @var: environment variable to set in form 'name[=value]', * @replace: TRUE if @name should be overwritten if already set, else * FALSE. * @@ -151,11 +151,25 @@ int job_class_environment_set (const char *var, int replace) { + nih_local char *envvar = NULL; + nih_assert (var); job_class_environment_init (); - if (! environ_add (&job_environ, NULL, NULL, replace, var)) + /* If variable does not contain a delimiter, add one to ensure + * it gets entered into the job environment table. Without the + * delimiter, the variable will be silently ignored unless it's + * already set in inits environment. But in that case there is + * no point in setting such a variable to its already existing + * value. + */ + if (! strchr (var, '=')) + envvar = NIH_MUST (nih_sprintf (NULL, "%s=", var)); + else + envvar = NIH_MUST (nih_strdup (NULL, var)); + + if (! environ_add (&job_environ, NULL, NULL, replace, envvar)) return -1; return 0; === modified file 'util/initctl.c' --- util/initctl.c 2013-01-09 10:13:36 +0000 +++ util/initctl.c 2013-01-09 11:13:03 +0000 @@ -1499,7 +1499,7 @@ } /** - * list_env_strcmp_compar: + * list_env_qsort_compar: * * @a: first string to compare, * @b: second string to compare. @@ -1507,9 +1507,9 @@ * qsort() function to sort environment variables for list_env_action(). **/ static int -list_env_strcmp_compar (const void *a, const void *b) +list_env_qsort_compar (const void *a, const void *b) { - return strcasecmp (*(char * const *)a, *(char * const *)b); + return strcoll (*(char * const *)a, *(char * const *)b); } /** @@ -1519,7 +1519,7 @@ * * This function is called for the "list-env" command. * - * Output is in case-insensitive lexicographically sorted order. + * Output is in lexicographically sorted order. * * Returns: command exit status. **/ @@ -1546,7 +1546,7 @@ for (len = 0; env[len]; len++) ; - qsort (env, len, sizeof (env[0]), list_env_strcmp_compar); + qsort (env, len, sizeof (env[0]), list_env_qsort_compar); for (e = env; e && *e; e++) nih_message ("%s", *e); === modified file 'util/man/initctl.8' --- util/man/initctl.8 2012-08-31 21:01:48 +0000 +++ util/man/initctl.8 2013-01-09 11:13:03 +0000 @@ -548,21 +548,62 @@ .RE .\" .TP +.B get-env +.I VARIABLE + +Query the value of the specified variable in the job environment table. +.\" +.TP +.B set-env +.RI [ OPTIONS "] " VARIABLE[=VALUE] + +Adds or updates a variable in the job environment table. Variables set +in this way will apply to all subsequently-starting jobs. + +.B OPTIONS +.RS +.IP "\fB\-r\fP, \fB\-\-retain\fP" + +If the specified variable is already set, do not modify it. +.RE +.\" +.TP +.B unset-env +.I VARIABLE + +Remove the specified variable from the job environment table. If the +variable does not already exist in the table, no change will be made. +.\" +.TP +.B list-env + +Display a lexicographically sorted list of all variables and their +values in the job environment table. +.\" +.TP +.B reset-env + +Discards all changes make to the job environment table, setting it back +to its default set of variables and values. +.\" +.TP .B usage .I JOB .RI [ KEY=VALUE ]... -Show usage information an instance of the named -.IR JOB -defined with +Show usage information for the named +.IR JOB "." +If the job specified does not define the .BR usage -stanza. +stanza, a blank usage will be displayed. -For job with +Example output for a job that specifies the .BR usage -stanza a line like the following is output, see +stanza is shown below. See .BR init (5) -: +for further details of the +.B usage +stanza: .nf Usage: tty DEV=ttyX - where X is console id @@ -585,6 +626,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .\" .SH SEE ALSO +.BR init (5) .BR init (8) .BR telinit (8) .BR shutdown (8)
-- upstart-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel
