static int argc; /* The number of arguments present in ARGV. */
static char **argv; /* The argument list. */
-static bool test_unop (char const *s);
static bool unary_operator (void);
static bool binary_operator (bool);
static bool two_arguments (void);
/* It might be a switch type argument. */
else if (argv[pos][0] == '-' && argv[pos][1] && argv[pos][2] == '\0')
- {
- if (test_unop (argv[pos]))
- value = unary_operator ();
- else
- test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
- }
+ value = unary_operator ();
else
{
value = (argv[pos][0] != '\0');
switch (argv[pos][1])
{
default:
+ test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
return false;
/* All of the following unary operators use unary_advance (), which
return or (); /* Same with this. */
}
-/* Return true if OP is one of the test command's unary operators. */
-static bool
-test_unop (char const *op)
-{
- if (op[0] != '-')
- return false;
-
- switch (op[1])
- {
- case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'k': case 'n':
- case 'o': case 'p': case 'r': case 's': case 't':
- case 'u': case 'w': case 'x': case 'z':
- case 'G': case 'L': case 'O': case 'S': case 'N':
- return true;
- default:
- return false;
- }
-}
-
static bool
one_argument (void)
{
&& argv[pos][1] != '\0'
&& argv[pos][2] == '\0')
{
- if (test_unop (argv[pos]))
- value = unary_operator ();
- else
- test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
+ value = unary_operator ();
}
else
beyond ();
my @Tests =
(
# In coreutils-5.93, this diagnostic lacked the newline.
- ['o', '-o arg', {ERR => "test: extra argument '-o'\n"},
- {ERR_SUBST => 's!^.*:!test:!'},
+ ['o', '-o arg', {ERR => "test: '-o': unary operator expected\n"},
+ {ERR_SUBST => 's!^.*test:!test:!'},
{EXIT => 2}],
);