mirror of
https://github.com/coreutils/coreutils.git
synced 2024-11-28 12:35:36 +08:00
test: accept "==" as a synonym for "="
Make GNU coreutils' test recognize "==" as a synonym for "=". This is already the case in GNU coreutils' expr, bash, ksh, busybox ash, FreeBSD-current /bin/sh and /bin/test, and OpenBSD's /bin/sh. Before, env test a '==' a would fail with this diagnostic: "test: ==: binary operator expected". Now, it succeeds. * src/test.c: Accept "==" as a synonym for "=". * doc/coreutils.texi (String tests): Document it. Reported as http://debbugs.gnu.org/8263 Also see http://austingroupbugs.net/view.php?id=375
This commit is contained in:
parent
2a3a094e0d
commit
3f31ec950b
@ -11535,7 +11535,7 @@ Exit status:
|
||||
* File type tests:: -[bcdfhLpSt]
|
||||
* Access permission tests:: -[gkruwxOG]
|
||||
* File characteristic tests:: -e -s -nt -ot -ef
|
||||
* String tests:: -z -n = !=
|
||||
* String tests:: -z -n = == !=
|
||||
* Numeric tests:: -eq -ne -lt -le -gt -ge
|
||||
* Connectives for test:: ! -a -o
|
||||
@end menu
|
||||
@ -11726,6 +11726,11 @@ True if the length of @var{string} is nonzero.
|
||||
@cindex equal string check
|
||||
True if the strings are equal.
|
||||
|
||||
@item @var{string1} == @var{string2}
|
||||
@opindex ==
|
||||
@cindex equal string check
|
||||
True if the strings are equal (synonym for =).
|
||||
|
||||
@item @var{string1} != @var{string2}
|
||||
@opindex !=
|
||||
@cindex not-equal string check
|
||||
|
@ -173,7 +173,8 @@ get_mtime (char const *filename, struct timespec *mtime)
|
||||
static bool
|
||||
binop (char const *s)
|
||||
{
|
||||
return ((STREQ (s, "=")) || (STREQ (s, "!=")) || (STREQ (s, "-nt")) ||
|
||||
return ((STREQ (s, "=")) || (STREQ (s, "!=")) || (STREQ (s, "==")) ||
|
||||
(STREQ (s, "-nt")) ||
|
||||
(STREQ (s, "-ot")) || (STREQ (s, "-ef")) || (STREQ (s, "-eq")) ||
|
||||
(STREQ (s, "-ne")) || (STREQ (s, "-lt")) || (STREQ (s, "-le")) ||
|
||||
(STREQ (s, "-gt")) || (STREQ (s, "-ge")));
|
||||
@ -360,7 +361,8 @@ binary_operator (bool l_is_l)
|
||||
test_syntax_error (_("unknown binary operator"), argv[op]);
|
||||
}
|
||||
|
||||
if (argv[op][0] == '=' && !argv[op][1])
|
||||
if (argv[op][0] == '=' && (!argv[op][1] ||
|
||||
((argv[op][1] == '=') && !argv[op][2])))
|
||||
{
|
||||
bool value = STREQ (argv[pos], argv[pos + 2]);
|
||||
pos += 3;
|
||||
|
Loading…
Reference in New Issue
Block a user