more error checking for hash builtin; fix for [[ builtin and some test syntax errors

This commit is contained in:
Chet Ramey
2023-09-13 16:25:28 -04:00
parent 32826f717d
commit 94bce520e8
25 changed files with 1898 additions and 1707 deletions
+22 -2
View File
@@ -118,6 +118,9 @@ static void test_syntax_error (char *, char *) __attribute__((__noreturn__));
static void beyond (void) __attribute__((__noreturn__));
static void integer_expected_error (char *) __attribute__((__noreturn__));
static int unary_test (char *, char *, int);
static int binary_test (char *, char *, char *, int);
static int unary_operator (void);
static int binary_operator (void);
static int two_arguments (void);
@@ -376,7 +379,7 @@ patcomp (char *string, char *pat, int op)
return ((op == EQ) ? (m == 0) : (m != 0));
}
int
static int
binary_test (char *op, char *arg1, char *arg2, int flags)
{
int patmatch;
@@ -509,7 +512,7 @@ unary_operator (void)
return (unary_test (op, argv[pos - 1], 0));
}
int
static int
unary_test (char *op, char *arg, int flags)
{
intmax_t r;
@@ -857,6 +860,23 @@ posixtest (void)
return (value);
}
#if defined (COND_COMMAND)
int
cond_test (char *op, char *arg1, char *arg2, int flags)
{
int code, ret;
code = setjmp_nosigs (test_exit_buf);
if (code)
return (test_error_return);
ret = arg2 ? binary_test (op, arg1, arg2, flags) : unary_test (op, arg1, flags);
return (ret ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
#endif
/*
* [:
* '[' expr ']'