Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [[ str == pat ]] ?



Glenn Barry wrote:
> most excellant zsh workers,
> 
> According to the "Korn Shell Ref" card (updated for ksh93) from SSC
> 
> 	[[ str == pat ]]
> 
> is preferred  and 
> 
> 	[[ str = pat ]] 
> 
> is "obsolete" (but still works of course).
> 
> Can the == for [[ be added to zsh?  We've got some code that
> needs to work on both ksh and zsh so it would be nice...

My ksh manual from Solaris 5.4 (Last change: 3 Aug 1993) does not mention
this, but I tried the ksh here, and it accepted the == syntax.  Here is a
patch to zsh to do that.  This makes [[ ... = ... ]] and [[ ... == ... ]]
equivalent.

Could you post your ksh documentation?

Cheers,
  Zoltan

*** 1.4	1995/10/10 18:24:53
--- Src/parse.c	1995/10/12 11:30:30
***************
*** 1320,1326 ****
      Cond n = (Cond) make_cond();
      int t0;
  
!     if ((b[0] == Equals || b[0] == '=') && !b[1])
  	n->type = COND_STREQ;
      else if (b[0] == '!' && (b[1] == Equals || b[1] == '=') && !b[2])
  	n->type = COND_STRNEQ;
--- 1320,1327 ----
      Cond n = (Cond) make_cond();
      int t0;
  
!     if ((b[0] == Equals || b[0] == '=') &&
! 	(!b[1] || ((b[1] == Equals || b[1] == '=') && !b[2])))
  	n->type = COND_STREQ;
      else if (b[0] == '!' && (b[1] == Equals || b[1] == '=') && !b[2])
  	n->type = COND_STRNEQ;
*** 1.4	1995/10/10 20:13:12
--- Doc/zshmisc.1	1995/10/12 12:05:23
***************
*** 997,1003 ****
--- 997,1007 ----
  .I file2
  exist and refer to the same file.
  .TP
+ .PD 0
+ \fIstring\fP \fB==\fP \fIpattern\fP
+ .TP
  \fIstring\fP \fB=\fP \fIpattern\fP
+ .PD
  true if
  .I string
  matches



Messages sorted by: Reverse Date, Date, Thread, Author