From: Trent Huber Date: Mon, 15 Jun 2026 00:40:07 +0000 (-0400) Subject: Bug fix for prompt() X-Git-Url: http://trenthuber.com/code?a=commitdiff_plain;h=e3d0b539c44787ea64b1e35436652eb0d86f8a85;p=thus.git Bug fix for prompt() --- diff --git a/src/input.c b/src/input.c index 4b751a3..7cf395d 100644 --- a/src/input.c +++ b/src/input.c @@ -75,16 +75,18 @@ static void moveright(void) { } static void prompt(void) { - char *p, *oldstart, *oldcursor; + char *p, buffer[MAXCHARS + 1], *oldstart, *oldcursor; - if (!(p = getenv("PROMPT"))) - fatal("Unable to access $PROMPT$ environment variable"); + if (!(p = getenv("PROMPT")) && setenv("PROMPT", p = ">", 1) == -1) + fatal("Unable to update $PROMPT$ environment variable"); + strcpy(buffer, p); + strcat(buffer, " "); oldstart = start; oldcursor = cursor; promptlen = 0; - cursor = start = p; + cursor = start = buffer; while (*cursor) moveright(); promptlen = cursor - start;