-/* $OpenBSD: const.c,v 1.8 2015/10/26 16:27:04 naddy Exp $ */
+/* $OpenBSD: const.c,v 1.9 2017/12/12 00:18:58 tb Exp $ */
/* $NetBSD: const.c,v 1.6 1995/03/21 09:02:31 cgd Exp $ */
/*-
'a', 'l', 'u', 'e', '\0' };
Char STRprompt[] = { 'p', 'r', 'o', 'm', 'p', 't', '\0' };
Char STRprompt2[] = { 'p', 'r', 'o', 'm', 'p', 't', '2', '\0' };
+Char STRpromptroot[] = { '%', 'm', '#', ' ', '\0' };
+Char STRpromptuser[] = { '%', 'm', '%', ' ', '\0' };
Char STRpushdsilent[] = { 'p', 'u', 's', 'h', 'd', 's', 'i', 'l', 'e', 'n',
't', '\0' };
Char STRret[] = { '\n', '\0' };
Char STRsporsp[] = { ' ', '|', ' ', '\0' };
Char STRstar[] = { '*', '\0' };
Char STRstatus[] = { 's', 't', 'a', 't', 'u', 's', '\0' };
-Char STRsymcent[] = { '%', ' ', '\0' };
-Char STRsymhash[] = { '#', ' ', '\0' };
Char STRterm[] = { 't', 'e', 'r', 'm', '\0' };
Char STRthen[] = { 't', 'h', 'e', 'n', '\0' };
Char STRtilde[] = { '~', '\0' };
-/* $OpenBSD: csh.c,v 1.41 2017/08/30 06:42:21 anton Exp $ */
+/* $OpenBSD: csh.c,v 1.42 2017/12/12 00:18:58 tb Exp $ */
/* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */
/*-
* Set up the prompt.
*/
if (prompt) {
- set(STRprompt, Strsave(uid == 0 ? STRsymhash : STRsymcent));
+ set(STRprompt, Strsave(uid == 0 ? STRpromptroot : STRpromptuser));
/* that's a meta-questionmark */
set(STRprompt2, Strsave(STRmquestion));
}
for (cp = value(STRprompt); *cp; cp++)
if (*cp == HIST)
(void) fprintf(cshout, "%d", eventno + 1);
- else {
+ else if (*cp == '%' && *(cp + 1) == 'm') {
+ char hostname[HOST_NAME_MAX + 1];
+ char *p;
+
+ gethostname(hostname, sizeof hostname);
+ if ((p = strchr(hostname, '.')) != NULL)
+ *p = '\0';
+ fprintf(cshout, "%s", hostname);
+ cp++;
+ } else {
if (*cp == '\\' && cp[1] == HIST)
cp++;
(void) vis_fputc(*cp | QUOTE, cshout);
-/* $OpenBSD: lex.c,v 1.72 2017/12/07 01:54:33 tb Exp $ */
+/* $OpenBSD: lex.c,v 1.73 2017/12/12 00:18:58 tb Exp $ */
/*
* lexical analysis and source input
cp++;
if (!*cp)
break;
- if (Flag(FSH))
+ /* Expand \h and \$ for both, sh(1) and ksh(1) */
+ if (Flag(FSH) && !(*cp == 'h' || *cp == 'p'))
snprintf(strbuf, sizeof strbuf, "\\%c", *cp);
else switch (*cp) {
case 'a': /* '\' 'a' bell */
-/* $OpenBSD: main.c,v 1.84 2017/12/07 01:54:33 tb Exp $ */
+/* $OpenBSD: main.c,v 1.85 2017/12/12 00:18:58 tb Exp $ */
/*
* startup, main loop, environments and error handling
/* Set PS1 if it isn't set */
if (!(vp->flag & ISSET)) {
/* setstr can't fail here */
- setstr(vp, safe_prompt, KSH_RETURN_ERROR);
+ setstr(vp, "\\h\\$ ", KSH_RETURN_ERROR);
}
}