summaryrefslogtreecommitdiffstats
path: root/cmd-show-environment.c
diff options
context:
space:
mode:
authornicm <nicm>2016-10-16 19:04:05 +0000
committernicm <nicm>2016-10-16 19:04:05 +0000
commitb342bd0b462f69a9fc9a59d52bcd4bb34b57114f (patch)
tree2da71181e3b540b8b52422cb598682f1505c2e89 /cmd-show-environment.c
parentddc4512d2e0eda6c705e002cb5dbf80719d709e1 (diff)
Mass rename struct cmd_q to struct cmdq_item and related.
Diffstat (limited to 'cmd-show-environment.c')
-rw-r--r--cmd-show-environment.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/cmd-show-environment.c b/cmd-show-environment.c
index 659acfad..8b38de2c 100644
--- a/cmd-show-environment.c
+++ b/cmd-show-environment.c
@@ -27,10 +27,11 @@
* Show environment.
*/
-static enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_q *);
+static enum cmd_retval cmd_show_environment_exec(struct cmd *,
+ struct cmdq_item *);
static char *cmd_show_environment_escape(struct environ_entry *);
-static void cmd_show_environment_print(struct cmd *, struct cmd_q *,
+static void cmd_show_environment_print(struct cmd *, struct cmdq_item *,
struct environ_entry *);
const struct cmd_entry cmd_show_environment_entry = {
@@ -65,30 +66,30 @@ cmd_show_environment_escape(struct environ_entry *envent)
}
static void
-cmd_show_environment_print(struct cmd *self, struct cmd_q *cmdq,
+cmd_show_environment_print(struct cmd *self, struct cmdq_item *item,
struct environ_entry *envent)
{
char *escaped;
if (!args_has(self->args, 's')) {
if (envent->value != NULL)
- cmdq_print(cmdq, "%s=%s", envent->name, envent->value);
+ cmdq_print(item, "%s=%s", envent->name, envent->value);
else
- cmdq_print(cmdq, "-%s", envent->name);
+ cmdq_print(item, "-%s", envent->name);
return;
}
if (envent->value != NULL) {
escaped = cmd_show_environment_escape(envent);
- cmdq_print(cmdq, "%s=\"%s\"; export %s;", envent->name, escaped,
+ cmdq_print(item, "%s=\"%s\"; export %s;", envent->name, escaped,
envent->name);
free(escaped);
} else
- cmdq_print(cmdq, "unset %s;", envent->name);
+ cmdq_print(item, "unset %s;", envent->name);
}
static enum cmd_retval
-cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
+cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct environ *env;
@@ -96,8 +97,8 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
const char *target;
if ((target = args_get(args, 't')) != NULL) {
- if (cmdq->state.tflag.s == NULL) {
- cmdq_error(cmdq, "no such session: %s", target);
+ if (item->state.tflag.s == NULL) {
+ cmdq_error(item, "no such session: %s", target);
return (CMD_RETURN_ERROR);
}
}
@@ -105,30 +106,30 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(self->args, 'g'))
env = global_environ;
else {
- if (cmdq->state.tflag.s == NULL) {
+ if (item->state.tflag.s == NULL) {
target = args_get(args, 't');
if (target != NULL)
- cmdq_error(cmdq, "no such session: %s", target);
+ cmdq_error(item, "no such session: %s", target);
else
- cmdq_error(cmdq, "no current session");
+ cmdq_error(item, "no current session");
return (CMD_RETURN_ERROR);
}
- env = cmdq->state.tflag.s->environ;
+ env = item->state.tflag.s->environ;
}
if (args->argc != 0) {
envent = environ_find(env, args->argv[0]);
if (envent == NULL) {
- cmdq_error(cmdq, "unknown variable: %s", args->argv[0]);
+ cmdq_error(item, "unknown variable: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
- cmd_show_environment_print(self, cmdq, envent);
+ cmd_show_environment_print(self, item, envent);
return (CMD_RETURN_NORMAL);
}
envent = environ_first(env);
while (envent != NULL) {
- cmd_show_environment_print(self, cmdq, envent);
+ cmd_show_environment_print(self, item, envent);
envent = environ_next(envent);
}
return (CMD_RETURN_NORMAL);