Skip to content

Commit 326e215

Browse files
committed
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
1 parent eae5184 commit 326e215

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/bin/psql/prompt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.9 2000/02/16 13:15:26 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.10 2000/03/08 01:38:59 momjian Exp $
77
*/
88
#include "postgres.h"
99
#include "prompt.h"
@@ -19,7 +19,7 @@
1919
#include <win32.h>
2020
#endif
2121

22-
22+
#include <sys/utsname.h>
2323

2424
/*--------------------------
2525
* get_prompt
@@ -121,8 +121,17 @@ get_prompt(promptStatus_t status)
121121
if (*p == 'm')
122122
buf[strcspn(buf, ".")] = '\0';
123123
}
124-
else
124+
else if (*p == 'M')
125125
buf[0] = '.';
126+
else
127+
{
128+
struct utsname ubuf;
129+
130+
if (uname(&ubuf) < 0)
131+
buf[0] = '.';
132+
else
133+
strncpy(buf, ubuf.nodename, MAX_PROMPT_SIZE);
134+
}
126135
}
127136
break;
128137
/* DB server port number */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy