summaryrefslogtreecommitdiffstats
path: root/cmd-set-environment.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-11 12:53:37 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-11 12:53:37 +0000
commit60db6e3df471142e4ee7773b9b4e9b0135d61dfc (patch)
treebf979af8451bb6e38ef6db99f9c568e2c79f3129 /cmd-set-environment.c
parentedcb22a6fb51f7862ffe694df8c0bdaffdaa8895 (diff)
Add flags for 1+2 and 2 arguments to the generic target code, use it for
cmd-set-environment/option/window-option and remove the generic options parsing.
Diffstat (limited to 'cmd-set-environment.c')
-rw-r--r--cmd-set-environment.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/cmd-set-environment.c b/cmd-set-environment.c
index 85399a94..4ba66a07 100644
--- a/cmd-set-environment.c
+++ b/cmd-set-environment.c
@@ -31,27 +31,27 @@ int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
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'),
+ "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
+ CMD_ARG12, CMD_CHFLAG('g')|CMD_CHFLAG('r')|CMD_CHFLAG('u'),
NULL,
- cmd_option_parse,
+ cmd_target_parse,
cmd_set_environment_exec,
- cmd_option_free,
- cmd_option_print
+ cmd_target_free,
+ cmd_target_print
};
int
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_option_data *data = self->data;
+ struct cmd_target_data *data = self->data;
struct session *s;
struct environ *env;
- if (*data->option == '\0') {
+ if (*data->arg == '\0') {
ctx->error(ctx, "empty variable name");
return (-1);
}
- if (strchr(data->option, '=') != NULL) {
+ if (strchr(data->arg, '=') != NULL) {
ctx->error(ctx, "variable name contains =");
return (-1);
}
@@ -65,23 +65,23 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
}
if (data->chflags & CMD_CHFLAG('u')) {
- if (data->value != NULL) {
+ if (data->arg2 != NULL) {
ctx->error(ctx, "can't specify a value with -u");
return (-1);
}
- environ_unset(env, data->option);
+ environ_unset(env, data->arg);
} else if (data->chflags & CMD_CHFLAG('r')) {
- if (data->value != NULL) {
+ if (data->arg2 != NULL) {
ctx->error(ctx, "can't specify a value with -r");
return (-1);
}
- environ_set(env, data->option, NULL);
+ environ_set(env, data->arg, NULL);
} else {
- if (data->value == NULL) {
+ if (data->arg2 == NULL) {
ctx->error(ctx, "no value specified");
return (-1);
}
- environ_set(env, data->option, data->value);
+ environ_set(env, data->arg, data->arg2);
}
return (0);