From: Bruce Momjian Date: Wed, 8 Mar 2000 01:38:59 +0000 (+0000) Subject: Hi Peter, X-Git-Tag: REL7_0~483 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=326e2155d9f30e235b6b25c0cecce1e60f90d8e8;p=postgresql Hi Peter, I try change prompt in the psql, but it is set '.' (as '%m') for non-TCP/IP connection. This small patch try use uname() information for non-TCP/IP instead '.'. Karel --- diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 505f5fa830..efb2b1a3f6 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.9 2000/02/16 13:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.10 2000/03/08 01:38:59 momjian Exp $ */ #include "postgres.h" #include "prompt.h" @@ -19,7 +19,7 @@ #include #endif - +#include /*-------------------------- * get_prompt @@ -121,8 +121,17 @@ get_prompt(promptStatus_t status) if (*p == 'm') buf[strcspn(buf, ".")] = '\0'; } - else + else if (*p == 'M') buf[0] = '.'; + else + { + struct utsname ubuf; + + if (uname(&ubuf) < 0) + buf[0] = '.'; + else + strncpy(buf, ubuf.nodename, MAX_PROMPT_SIZE); + } } break; /* DB server port number */