aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-08-27 15:05:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-08-27 15:05:20 +0000
commit162e8f1fd53eb485e0b7c22331444f245420d3ba (patch)
tree54ca814c99dd045e7a6e9a72dccf75e5289b7ddf
parent445a61297e1b53d047347200b8398b03c7e82136 (diff)
downloadpostgresql-162e8f1fd53eb485e0b7c22331444f245420d3ba.tar.gz
postgresql-162e8f1fd53eb485e0b7c22331444f245420d3ba.zip
Make saveHistory work properly on OS X when HISTFILE is set to /dev/null.
Per discussion with Martin Atukunda.
-rw-r--r--src/bin/psql/input.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 4041177e4f1..3441d7813e2 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.57 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.58 2006/08/27 15:05:20 tgl Exp $
*/
#include "postgres_fe.h"
@@ -340,7 +340,14 @@ bool
saveHistory(char *fname, bool encodeFlag)
{
#ifdef USE_READLINE
- if (useHistory && fname)
+ /*
+ * Suppressing the write attempt when HISTFILE is set to /dev/null
+ * may look like a negligible optimization, but it's necessary on e.g.
+ * Darwin, where write_history will fail because it tries to chmod
+ * the target file.
+ */
+ if (useHistory && fname &&
+ strcmp(fname, DEVNULL) != 0)
{
if (encodeFlag)
encode_history();