File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 9
9
10
10
#ifndef WIN32
11
11
#include <unistd.h>
12
+ #else
13
+ #include <sys/types.h>
14
+ #include <sys/stat.h>
15
+ #include <errno.h>
12
16
#endif
13
17
#include <fcntl.h>
14
18
#include <limits.h>
@@ -366,7 +370,6 @@ initializeInput(int flags)
366
370
history_lines_added = 0 ;
367
371
368
372
histfile = GetVariable (pset .vars , "HISTFILE" );
369
-
370
373
if (histfile == NULL )
371
374
{
372
375
char * envhist ;
@@ -380,14 +383,24 @@ initializeInput(int flags)
380
383
{
381
384
if (get_home_path (home ))
382
385
#ifdef HAVE_WIN32_LIBEDIT
386
+ {
387
+ struct _stat buffer ;
383
388
psql_history = psprintf ("%s\\%s" , home , PSQLHISTORY );
389
+ /* Check if home exists and create it if needed,
390
+ because there is no guarantee that it exits on Win32 */
391
+ if (_stat (home ,& buffer )!= 0 && errno == ENOENT )
392
+ {
393
+ _mkdir (home );
394
+ }
395
+ }
384
396
#else
385
397
psql_history = psprintf ("%s/%s" , home , PSQLHISTORY );
386
398
#endif
387
399
}
388
400
else
389
401
{
390
402
psql_history = pg_strdup (histfile );
403
+ fprintf (stderr ,"Expanding tilde\n" );
391
404
expand_tilde (& psql_history );
392
405
}
393
406
You can’t perform that action at this time.
0 commit comments