about summary refs log tree commit diff
path: root/Src/prompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index 7bd4ed0f1..cca6da21f 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -201,7 +201,7 @@ promptexpand(char *s, int ns, char *rs, char *Rs)
 static int
 putpromptchar(int doprint, int endchar)
 {
-    char *ss, *tmbuf = NULL;
+    char *ss, *tmbuf = NULL, *hostnam;
     int t0, arg, test, sep;
     struct tm *tm;
     time_t timet;
@@ -372,11 +372,14 @@ putpromptchar(int doprint, int endchar)
 		bp += strlen(bp);
 		break;
 	    case 'M':
-		stradd(hostnam);
+		if ((hostnam = getsparam("HOST")))
+		    stradd(hostnam);
 		break;
 	    case 'm':
 		if (!arg)
 		    arg++;
+		if (!(hostnam = getsparam("HOST")))
+		    break;
 		if (arg < 0) {
 		    for (ss = hostnam + strlen(hostnam); ss > hostnam; ss--)
 			if (ss[-1] == '.' && !++arg)