show-* and set-* need to handle a missing target.

This commit is contained in:
nicm
2016-03-03 14:15:22 +00:00
parent fa81d838da
commit df0983af39
4 changed files with 73 additions and 32 deletions

View File

@ -47,7 +47,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct environ *env;
const char *name, *value;
const char *name, *value, *target;
name = args->argv[0];
if (*name == '\0') {
@ -64,10 +64,19 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
else
value = args->argv[1];
if (args_has(self->args, 'g') || cmdq->state.tflag.s == NULL)
if (args_has(self->args, 'g'))
env = global_environ;
else
else {
if (cmdq->state.tflag.s == NULL) {
target = args_get(args, 't');
if (target != NULL)
cmdq_error(cmdq, "no such session: %s", target);
else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
}
env = cmdq->state.tflag.s->environ;
}
if (args_has(self->args, 'u')) {
if (value != NULL) {