=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-set-environment.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/tmux/cmd-set-environment.c 2009/08/08 21:52:43 1.1 --- src/usr.bin/tmux/cmd-set-environment.c 2009/08/11 12:53:37 1.2 *************** *** 1,4 **** ! /* $OpenBSD: cmd-set-environment.c,v 1.1 2009/08/08 21:52:43 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-set-environment.c,v 1.2 2009/08/11 12:53:37 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 31,57 **** const struct cmd_entry cmd_set_environment_entry = { "set-environment", "setenv", ! "[-gru] " CMD_OPTION_SESSION_USAGE, ! 0, CMD_CHFLAG('g')|CMD_CHFLAG('r')|CMD_CHFLAG('u'), NULL, ! cmd_option_parse, cmd_set_environment_exec, ! cmd_option_free, ! cmd_option_print }; int cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx) { ! struct cmd_option_data *data = self->data; struct session *s; struct environ *env; ! if (*data->option == '\0') { ctx->error(ctx, "empty variable name"); return (-1); } ! if (strchr(data->option, '=') != NULL) { ctx->error(ctx, "variable name contains ="); return (-1); } --- 31,57 ---- const struct cmd_entry cmd_set_environment_entry = { "set-environment", "setenv", ! "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]", ! CMD_ARG12, CMD_CHFLAG('g')|CMD_CHFLAG('r')|CMD_CHFLAG('u'), NULL, ! cmd_target_parse, cmd_set_environment_exec, ! cmd_target_free, ! cmd_target_print }; int cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx) { ! struct cmd_target_data *data = self->data; struct session *s; struct environ *env; ! if (*data->arg == '\0') { ctx->error(ctx, "empty variable name"); return (-1); } ! if (strchr(data->arg, '=') != NULL) { ctx->error(ctx, "variable name contains ="); return (-1); } *************** *** 65,87 **** } if (data->chflags & CMD_CHFLAG('u')) { ! if (data->value != NULL) { ctx->error(ctx, "can't specify a value with -u"); return (-1); } ! environ_unset(env, data->option); } else if (data->chflags & CMD_CHFLAG('r')) { ! if (data->value != NULL) { ctx->error(ctx, "can't specify a value with -r"); return (-1); } ! environ_set(env, data->option, NULL); } else { ! if (data->value == NULL) { ctx->error(ctx, "no value specified"); return (-1); } ! environ_set(env, data->option, data->value); } return (0); --- 65,87 ---- } if (data->chflags & CMD_CHFLAG('u')) { ! if (data->arg2 != NULL) { ctx->error(ctx, "can't specify a value with -u"); return (-1); } ! environ_unset(env, data->arg); } else if (data->chflags & CMD_CHFLAG('r')) { ! if (data->arg2 != NULL) { ctx->error(ctx, "can't specify a value with -r"); return (-1); } ! environ_set(env, data->arg, NULL); } else { ! if (data->arg2 == NULL) { ctx->error(ctx, "no value specified"); return (-1); } ! environ_set(env, data->arg, data->arg2); } return (0);