}
}
- if (lastchar == '%' && *p == '%')
+ if (lastchar == '%' && *p == '%') {
lastchar = '\0';
- else
+ len--;
+ } else
lastchar = *p;
}
exit(1);
}
for (p = prompt, np = new_prompt; *p; p++) {
- if (lastchar == '%' && (*p == 'h' || *p == 'u')) {
+ if (lastchar == '%' && (*p == 'h' || *p == 'u' || *p == '%')) {
/* substiture user/host name */
if (*p == 'h') {
+ np--;
strcpy(np, shost);
np += strlen(shost);
} else if (*p == 'u') {
+ np--;
strcpy(np, user_name);
np += strlen(user_name);
}
else
lastchar = *p;
}
+ *np = '\0';
} else
new_prompt = prompt;