diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 78a80da3e..ee0bc82be 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -624,6 +624,21 @@ static int strlenChar(const char *z){ } /* +** Return true if zFile does not exist or if it is not an ordinary file. +*/ +#ifdef _WIN32 +# define notNormalFile(X) 0 +#else +static int notNormalFile(const char *zFile){ + struct stat x; + int rc; + memset(&x, 0, sizeof(x)); + rc = stat(zFile, &x); + return rc || !S_ISREG(x.st_mode); +} +#endif + +/* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer ** to the text. NULL is returned at end of file, or if malloc() @@ -8932,8 +8947,9 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; goto meta_command_exit; } - p->in = fopen(azArg[1], "rb"); - if( p->in==0 ){ + if( notNormalFile(azArg[1]) + || (p->in = fopen(azArg[1], "rb"))==0 + ){ utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); rc = 1; }else{ |