Hide struct args behind a couple of accessor functions.

This commit is contained in:
nicm
2021-08-20 19:50:16 +00:00
parent de94a344f6
commit 5f32b7d961
41 changed files with 355 additions and 306 deletions

View File

@ -101,7 +101,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item);
struct environ *env;
struct environ_entry *envent;
const char *tflag;
const char *tflag, *name = args_string(args, 0);
if ((tflag = args_get(args, 't')) != NULL) {
if (target->s == NULL) {
@ -124,10 +124,10 @@ cmd_show_environment_exec(struct cmd *self, struct cmdq_item *item)
env = target->s->environ;
}
if (args->argc != 0) {
envent = environ_find(env, args->argv[0]);
if (name != NULL) {
envent = environ_find(env, name);
if (envent == NULL) {
cmdq_error(item, "unknown variable: %s", args->argv[0]);
cmdq_error(item, "unknown variable: %s", name);
return (CMD_RETURN_ERROR);
}
cmd_show_environment_print(self, item, envent);