From f8c150da24c0aec653212705b9861b629004a7e6 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Sat, 21 Dec 2019 17:05:41 +0800 Subject: [PATCH] Fix the bug referred to in issue #990. [tbase-1386]. --- src/kit/shell/src/shellEngine.c | 14 +++++++++++--- src/kit/shell/src/shellImport.c | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index ac66ab15d9..b238a55c5a 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -16,12 +16,12 @@ #define _XOPEN_SOURCE #define _DEFAULT_SOURCE -#include #include "os.h" #include "shell.h" #include "shellCommand.h" #include "ttime.h" #include "tutil.h" + #include /**************** Global variables ****************/ @@ -295,7 +295,6 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { if (fname != NULL) { wordfree(&full_path); } - return; } /* Function to do regular expression check */ @@ -795,8 +794,17 @@ void source_file(TAOS *con, char *fptr) { 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); + wordfree(&full_path); free(cmd); return; diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index 3292aa8e04..1057634803 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -153,10 +153,20 @@ static void shellSourceFile(TAOS *con, char *fptr) { } 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); + wordfree(&full_path); + free(cmd); return; } -- GitLab