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

This commit is contained in:
hjxilinx 2019-12-21 17:05:41 +08:00
parent d69b1d1b3d
commit f8c150da24
2 changed files with 24 additions and 6 deletions

View File

@ -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[]) {
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) {
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;

View File

@ -154,9 +154,19 @@ 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 readable\n", fptr); fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
wordfree(&full_path); wordfree(&full_path);
free(cmd);
return;
}
if (access(fname, R_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path);
free(cmd);
return; return;
} }