提交 f8c150da 编写于 作者: H hjxilinx

Fix the bug referred to in issue #990. [tbase-1386].

上级 d69b1d1b
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include <inttypes.h>
#include "os.h" #include "os.h"
#include "shell.h" #include "shell.h"
#include "shellCommand.h" #include "shellCommand.h"
#include "ttime.h" #include "ttime.h"
#include "tutil.h" #include "tutil.h"
#include <regex.h> #include <regex.h>
/**************** Global variables ****************/ /**************** Global variables ****************/
...@@ -295,7 +295,6 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { ...@@ -295,7 +295,6 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
if (fname != NULL) { if (fname != NULL) {
wordfree(&full_path); wordfree(&full_path);
} }
return;
} }
/* Function to do regular expression check */ /* Function to do regular expression check */
...@@ -795,8 +794,17 @@ void source_file(TAOS *con, char *fptr) { ...@@ -795,8 +794,17 @@ void source_file(TAOS *con, char *fptr) {
char *fname = full_path.we_wordv[0]; char *fname = full_path.we_wordv[0];
if (access(fname, R_OK) == -1) { if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
wordfree(&full_path);
free(cmd);
return;
}
if (access(fname, R_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr); fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path); wordfree(&full_path);
free(cmd); free(cmd);
return; return;
......
...@@ -153,10 +153,20 @@ static void shellSourceFile(TAOS *con, char *fptr) { ...@@ -153,10 +153,20 @@ static void shellSourceFile(TAOS *con, char *fptr) {
} }
char *fname = full_path.we_wordv[0]; char *fname = full_path.we_wordv[0];
if (access(fname, R_OK) == -1) { if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
wordfree(&full_path);
free(cmd);
return;
}
if (access(fname, R_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr); fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path); wordfree(&full_path);
free(cmd);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册