From 14cd3f396fdf11272b0c7c1101b9c48f8d68f83d Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 14 Jul 2020 11:41:56 -0400 Subject: fix $MORE handling --- more.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/more.c b/more.c index 84f1185..f37aa5d 100644 --- a/more.c +++ b/more.c @@ -338,17 +338,19 @@ static void adjust_args(int *argc, char ***argv) char *env = getenv("MORE"); if (env) { char **newargv = malloc((*argc + 2) * sizeof(*newargv)); - newargv[0] = *argv[0]; + newargv[0] = (*argv)[0]; /* TODO: account for spaces in env */ newargv[1] = env; for (int i = 1; i < *argc; i++) { - newargv[i + 1] = *argv[i]; + newargv[i + 1] = (*argv)[i]; } + newargv[*argc + 1] = NULL; + *argv = newargv; - *argc++; + (*argc)++; } for (int i = 1; i < *argc; i++) { -- cgit v1.2.1