[PATCH] bltin/test: = and != are strcmp, not strcoll

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



117067  s1 = s2  True if the strings s1 and s2 are identical; otherwise, false.
117068  s1 != s2 True if the strings s1 and s2 are not identical; otherwise, false.
117069  s1 > s2  True if s1 collates after s2 in the current locale; otherwise, false.
117070  s1 < s2  True if s1 collates before s2 in the current locale; otherwise, false.

"identical" does not mean "collate equally";
this is the difference between sort | uniq and sort -u
---
This bug violates every POSIX issue i can find.

The manual is already correct.

 src/bltin/test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bltin/test.c b/src/bltin/test.c
index 06f6818..2e2790f 100644
--- a/src/bltin/test.c
+++ b/src/bltin/test.c
@@ -354,9 +354,9 @@ binop(void)
 		/* NOTREACHED */
 #endif
 	case STREQ:
-		return strcoll(opnd1, opnd2) == 0;
+		return strcmp(opnd1, opnd2) == 0;
 	case STRNE:
-		return strcoll(opnd1, opnd2) != 0;
+		return strcmp(opnd1, opnd2) != 0;
 	case STRLT:
 		return strcoll(opnd1, opnd2) < 0;
 	case STRGT:
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux