Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
54691d41
Commit
54691d41
authored
Nov 04, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix psql \e and \! for Win32.
parent
e48b9b55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
15 deletions
+45
-15
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_ctl/pg_ctl.c
+3
-3
src/bin/psql/command.c
src/bin/psql/command.c
+42
-12
No files found.
src/bin/pg_ctl/pg_ctl.c
View file @
54691d41
...
...
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.4
4 2004/10/27 19:44:14
momjian Exp $
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.4
5 2004/11/04 22:25:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -335,7 +335,7 @@ start_postmaster(void)
* http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
*/
if
(
log_file
!=
NULL
)
#if
!defined(WIN32)
/* Cygwin doesn't have START */
#if
ndef WIN32
/* Cygwin doesn't have START */
snprintf
(
cmd
,
MAXPGPATH
,
"%s
\"
%s
\"
%s%s <
\"
%s
\"
>>
\"
%s
\"
2>&1 &%s"
,
#else
snprintf
(
cmd
,
MAXPGPATH
,
"%sSTART /B
\"\"
\"
%s
\"
%s%s <
\"
%s
\"
>>
\"
%s
\"
2>&1%s"
,
...
...
@@ -343,7 +343,7 @@ start_postmaster(void)
SYSTEMQUOTE
,
postgres_path
,
pgdata_opt
,
post_opts
,
DEVNULL
,
log_file
,
SYSTEMQUOTE
);
else
#if
!defined(WIN32)
/* Cygwin doesn't have START */
#if
ndef WIN32
/* Cygwin doesn't have START */
snprintf
(
cmd
,
MAXPGPATH
,
"%s
\"
%s
\"
%s%s <
\"
%s
\"
2>&1 &%s"
,
#else
snprintf
(
cmd
,
MAXPGPATH
,
"%sSTART /B
\"\"
\"
%s
\"
%s%s <
\"
%s
\"
2>&1%s"
,
...
...
src/bin/psql/command.c
View file @
54691d41
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.1
29 2004/10/16 03:10:16
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.1
30 2004/11/04 22:25:14
momjian Exp $
*/
#include "postgres_fe.h"
#include "command.h"
...
...
@@ -23,6 +23,10 @@
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#ifndef WIN32_CLIENT_ONLY
#include <sys/types.h>
/* for umask() */
#include <sys/stat.h>
/* for stat() */
#endif
#endif
#include "libpq-fe.h"
...
...
@@ -1097,7 +1101,7 @@ editFile(const char *fname)
#ifndef WIN32
"exec "
#endif
"%s
'%s'"
,
editorName
,
fname
);
"%s
\"
%s
\"
\"
%s
\"
%s"
,
SYSTEMQUOTE
,
editorName
,
fname
,
SYSTEMQUOTE
);
result
=
system
(
sys
);
if
(
result
==
-
1
)
psql_error
(
"could not start editor
\"
%s
\"\n
"
,
editorName
);
...
...
@@ -1119,7 +1123,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
bool
error
=
false
;
int
fd
;
#ifndef WIN32
#ifndef WIN32
_CLIENT_ONLY
struct
stat
before
,
after
;
#endif
...
...
@@ -1130,13 +1134,35 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
{
/* make a temp file to edit */
#ifndef WIN32
const
char
*
tmpdir
env
=
getenv
(
"TMPDIR"
);
const
char
*
tmpdir
=
getenv
(
"TMPDIR"
);
snprintf
(
fnametmp
,
sizeof
(
fnametmp
),
"%s/psql.edit.%d.%d"
,
tmpdirenv
?
tmpdirenv
:
"/tmp"
,
geteuid
(),
(
int
)
getpid
());
if
(
!
tmpdir
)
tmpdir
=
"/tmp"
;
#else
char
tmpdir
[
MAXPGPATH
];
int
ret
;
ret
=
GetTempPath
(
MAXPGPATH
,
tmpdir
);
if
(
ret
==
0
||
ret
>
MAXPGPATH
)
{
psql_error
(
"Can not locate temporary directory: %s"
,
!
ret
?
strerror
(
errno
)
:
""
);
return
false
;
}
/*
* No canonicalize_path() here.
* EDIT.EXE run from CMD.EXE prepends the current directory to the
* supplied path unless we use only backslashes, so we do that.
*/
#endif
snprintf
(
fnametmp
,
sizeof
(
fnametmp
),
"%s%spsql.edit.%d"
,
tmpdir
,
#ifndef WIN32
"/"
,
#else
GetTempFileName
(
"."
,
"psql"
,
0
,
fnametmp
);
""
,
/* trailing separator already present */
#endif
(
int
)
getpid
());
fname
=
(
const
char
*
)
fnametmp
;
fd
=
open
(
fname
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0600
);
...
...
@@ -1174,7 +1200,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
}
}
#ifndef WIN32
#ifndef WIN32
_CLIENT_ONLY
if
(
!
error
&&
stat
(
fname
,
&
before
)
!=
0
)
{
psql_error
(
"%s: %s
\n
"
,
fname
,
strerror
(
errno
));
...
...
@@ -1186,7 +1212,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
if
(
!
error
)
error
=
!
editFile
(
fname
);
#ifndef WIN32
#ifndef WIN32
_CLIENT_ONLY
if
(
!
error
&&
stat
(
fname
,
&
after
)
!=
0
)
{
psql_error
(
"%s: %s
\n
"
,
fname
,
strerror
(
errno
));
...
...
@@ -1509,9 +1535,13 @@ do_shell(const char *command)
if
(
!
command
)
{
char
*
sys
;
const
char
*
shellName
;
const
char
*
shellName
=
NULL
;
shellName
=
getenv
(
"SHELL"
);
#ifdef WIN32
shellName
=
getenv
(
"COMSPEC"
);
#endif
if
(
shellName
==
NULL
)
shellName
=
getenv
(
"SHELL"
);
if
(
shellName
==
NULL
)
shellName
=
DEFAULT_SHELL
;
...
...
@@ -1520,7 +1550,7 @@ do_shell(const char *command)
#ifndef WIN32
"exec "
#endif
"%s
"
,
shellName
);
"%s
\"
%s
\"
%s"
,
SYSTEMQUOTE
,
shellName
,
SYSTEMQUOTE
);
result
=
system
(
sys
);
free
(
sys
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment