aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest14
-rw-r--r--manifest.uuid2
-rw-r--r--src/shell.c.in28
3 files changed, 30 insertions, 14 deletions
diff --git a/manifest b/manifest
index 5c89b7567..0fc98d596 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stests\sfor\slegacy\sgeometry\scallbacks\sto\srtreedoc2.test.
-D 2021-09-17T20:43:27.549
+C Shell's\s.read\spipe\snow\sworks\sfor\sWindows\stoo.
+D 2021-09-17T21:12:47.392
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -548,7 +548,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c 42b94d37a54200707a95566eff4f7e8a380e32d080016b699f23bd79a73a5028
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 030c3d07326708343208418c84da607752aebc13c92df929b7c68c7c08e7df54
-F src/shell.c.in 714fb58faf675ec7cc1b84a3e15a0791a6e2e376784c4f8d8ddf2135b64476ee
+F src/shell.c.in b6cf46c676e89a21dd70b2dfb1312116ae4411fc8140af56c794192c1c8270f2
F src/sqlite.h.in 4e977a5e2ed1a9e8987ff65a2cab5f99a4298ebf040ea5ff636e1753339ff45a
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h e97f4e9b509408fea4c4e9bef5a41608dfac343b4d3c7a990dedde1e19af9510
@@ -1925,7 +1925,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b7e00ef8059f6fb5658c6ad6f337cfdf065a5f1b1130452122282f3a69e98a93
-R 0b7caecd3af74a3c80ac98749a9df12e
-U dan
-Z 75db5feff0f016247e2a2ef39c35bcd5
+P 6ad00e52eda5bc4cb8e6fffbd7538bcd4c6b22f84b837a746eba6bf8c91eb55a
+R 4272cac65b9ce52e86aa091f7c699703
+U larrybr
+Z f2dab7d439a0b553d4ffc2b434c528dd
diff --git a/manifest.uuid b/manifest.uuid
index 536f28d9f..d0c60f0e4 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-6ad00e52eda5bc4cb8e6fffbd7538bcd4c6b22f84b837a746eba6bf8c91eb55a \ No newline at end of file
+929bcc4098549692c573779d65c4c28027b0a2f48ebbf5b3f038deee24374b67 \ No newline at end of file
diff --git a/src/shell.c.in b/src/shell.c.in
index a5ebfda33..cd8cd0bfa 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -635,20 +635,36 @@ static int strlenChar(const char *z){
}
/*
-** Return true if zFile does not exist or if it is not either
-** an ordinary file or an openable character stream source.
+** Return open FILE * if zFile exists, can be opened for read
+** and is an ordinary file or a character stream source.
+** Otherwise return 0.
*/
-static int notChrSource(const char *zFile){
+static FILE * openChrSource(const char *zFile){
#ifdef _WIN32
struct _stat x = {0};
- int rc = _stat(zFile, &x);
# define STAT_CHR_SRC(mode) ((mode & (_S_IFCHR|_S_IFIFO|_S_IFREG))!=0)
+ /* On Windows, open first, then check the stream nature. This order
+ ** is necessary because _stat() and sibs, when checking a named pipe,
+ ** effectively break the pipe as its supplier sees it. */
+ FILE *rv = fopen(zFile, "rb");
+ if( rv==0 ) return 0;
+ if( _fstat(_fileno(rv), &x) != 0
+ || !STAT_CHR_SRC(x.st_mode)){
+ fclose(rv);
+ rv = 0;
+ }
+ return rv;
#else
struct stat x = {0};
int rc = stat(zFile, &x);
# define STAT_CHR_SRC(mode) (S_ISREG(mode)||S_ISFIFO(mode)||S_ISCHR(mode))
+ if( rc!=0 ) return 0;
+ if( STAT_CHR_SRC(x.st_mode) ){
+ return fopen(zFile, "rb");
+ }else{
+ return 0;
+ }
#endif
- return rc || !STAT_CHR_SRC(x.st_mode);
#undef STAT_CHR_SRC
}
@@ -9242,7 +9258,7 @@ static int do_meta_command(char *zLine, ShellState *p){
pclose(p->in);
}
#endif
- }else if( notChrSource(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){
+ }else if( (p->in = openChrSource(azArg[1]))==0 ){
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
}else{