issue修复:gs_basebackup因新增参数校验导致重定向功能失效修复

This commit is contained in:
teooooozhang
2023-09-13 15:31:48 +08:00
parent 02c92d5e6f
commit a0e4d6cf1a

View File

@ -1960,13 +1960,11 @@ static int GsBaseBackup(int argc, char** argv)
int i; int i;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
char *optstr = argv[i]; char *optstr = argv[i];
int is_only_shortbar; if (strlen(optstr) == 1 && optstr[0] == '-') {
if (strlen(optstr) == 1) { /* ignore the case of redirecting output like "gs_probackup ... -D -> xxx.tar.gz" */
is_only_shortbar = optstr[0] == '-' ? 1 : 0; if (i > 0 && strcmp(argv[i - 1], "-D") == 0) {
} else { continue;
is_only_shortbar = 0; }
}
if (is_only_shortbar) {
fprintf(stderr, _("%s: The option '-' is not a valid option.\n"), progname); fprintf(stderr, _("%s: The option '-' is not a valid option.\n"), progname);
exit(1); exit(1);
} }
@ -1986,9 +1984,11 @@ static int GsBaseBackup(int argc, char** argv)
} }
char *next_optstr = argv[i + 1]; char *next_optstr = argv[i + 1];
if (strcmp(optstr, "-D") == 0 && strcmp(next_optstr, "-") == 0) {
continue;
}
char *next_oli = strchr(optstring, next_optstr[1]); char *next_oli = strchr(optstring, next_optstr[1]);
int is_arg_optionform = next_optstr[0] == '-' && next_oli != NULL; if (next_optstr[0] == '-' && next_oli != NULL) {
if (is_arg_optionform) {
fprintf(stderr, _("%s: The option '-%c' need a parameter.\n"), progname, optstr[1]); fprintf(stderr, _("%s: The option '-%c' need a parameter.\n"), progname, optstr[1]);
exit(1); exit(1);
} }