mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
Mass rename struct cmd_q to struct cmdq_item and related.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user