version 1.23, 2020/03/31 17:14:40 |
version 1.24, 2020/04/13 08:26:27 |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item) |
cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = cmd_get_args(self); |
struct environ *env; |
struct environ *env; |
const char *name, *value, *target; |
const char *name, *value, *target; |
|
|
|
|
else |
else |
value = args->argv[1]; |
value = args->argv[1]; |
|
|
if (args_has(self->args, 'g')) |
if (args_has(args, 'g')) |
env = global_environ; |
env = global_environ; |
else { |
else { |
if (item->target.s == NULL) { |
if (item->target.s == NULL) { |
|
|
env = item->target.s->environ; |
env = item->target.s->environ; |
} |
} |
|
|
if (args_has(self->args, 'u')) { |
if (args_has(args, 'u')) { |
if (value != NULL) { |
if (value != NULL) { |
cmdq_error(item, "can't specify a value with -u"); |
cmdq_error(item, "can't specify a value with -u"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
environ_unset(env, name); |
environ_unset(env, name); |
} else if (args_has(self->args, 'r')) { |
} else if (args_has(args, 'r')) { |
if (value != NULL) { |
if (value != NULL) { |
cmdq_error(item, "can't specify a value with -r"); |
cmdq_error(item, "can't specify a value with -r"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |