summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2006-08-27 15:05:20 +0000
committerTom Lane2006-08-27 15:05:20 +0000
commit96729f2f3bfdb066c01bef437e6e9c332c367211 (patch)
tree527629fd78aaa8c7d7ffec4eb88f844ed6a9a176
parentc0a3fd4a314ace796cd9e5191b3c7a448a736a9b (diff)
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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 68c946f2f9..9b359ccf0b 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -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();