}
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;