Skip to content

Commit 162e8f1

Browse files
committed
Make saveHistory work properly on OS X when HISTFILE is set to /dev/null.
Per discussion with Martin Atukunda.
1 parent 445a612 commit 162e8f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/bin/psql/input.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.57 2006/07/14 14:52:26 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.58 2006/08/27 15:05:20 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99

@@ -340,7 +340,14 @@ bool
340340
saveHistory(char *fname, bool encodeFlag)
341341
{
342342
#ifdef USE_READLINE
343-
if (useHistory && fname)
343+
/*
344+
* Suppressing the write attempt when HISTFILE is set to /dev/null
345+
* may look like a negligible optimization, but it's necessary on e.g.
346+
* Darwin, where write_history will fail because it tries to chmod
347+
* the target file.
348+
*/
349+
if (useHistory && fname &&
350+
strcmp(fname, DEVNULL) != 0)
344351
{
345352
if (encodeFlag)
346353
encode_history();

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