Subject: test: ==: unexpected operator
To: None <tech-userlevel@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-userlevel
Date: 09/22/2006 02:06:08
bash/Linux allows "==" as an alternative to "=" in their test(1) command.
I wonder if we want to save some trouble and just make our test(1) 
silently accept that too, instead of fixing all the broken scripts out 
there.

It'd be an extension to POSIX, so I don't see much of a problem.

Any thoughts?


  - Hubert


Index: test.c
===================================================================
RCS file: /cvsroot/src/bin/test/test.c,v
retrieving revision 1.28
diff -u -r1.28 test.c
--- test.c	4 Aug 2006 19:07:55 -0000	1.28
+++ test.c	22 Sep 2006 00:04:42 -0000
@@ -39,7 +39,7 @@
  	unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
  		"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";

-	binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
+	binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
  			"-nt"|"-ot"|"-ef";
  	operand ::= <any legal UNIX file name>
  */
@@ -121,6 +121,7 @@
  	{"-L",	FILSYM,	UNOP},
  	{"-S",	FILSOCK,UNOP},
  	{"=",	STREQ,	BINOP},
+	{"==",	STREQ,	BINOP},		/* bash compatibility */
  	{"!=",	STRNE,	BINOP},
  	{"<",	STRLT,	BINOP},
  	{">",	STRGT,	BINOP},


P.S.: As an alternative we could add some swearing at the user to use 
proper POSIX syntax and whatnot. I'm sure you will come up with something 
fancy. 8-)