zsh-workers
 help / color / mirror / code / Atom feed
* [[ str == pat ]] ?
@ 1995-10-12  5:42 Glenn Barry
  1995-10-12 12:07 ` Zoltan Hidvegi
  0 siblings, 1 reply; 5+ messages in thread
From: Glenn Barry @ 1995-10-12  5:42 UTC (permalink / raw)
  To: zsh-workers


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...

thx,
glenn



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [[ str == pat ]] ?
  1995-10-12  5:42 [[ str == pat ]] ? Glenn Barry
@ 1995-10-12 12:07 ` Zoltan Hidvegi
  1995-10-12 18:19   ` ksh compatibility Richard Coleman
  1995-10-12 20:36   ` [[ str == pat ]] ? Glenn Barry
  0 siblings, 2 replies; 5+ messages in thread
From: Zoltan Hidvegi @ 1995-10-12 12:07 UTC (permalink / raw)
  To: glenn; +Cc: zsh-workers

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* ksh compatibility
  1995-10-12 12:07 ` Zoltan Hidvegi
@ 1995-10-12 18:19   ` Richard Coleman
  1995-10-12 20:36   ` [[ str == pat ]] ? Glenn Barry
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Coleman @ 1995-10-12 18:19 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: 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.

Notice that he said ksh93.  I think Solaris uses ksh89.

Also, I will probably add this since I think == is a more logical way
of representing this.  But I must stress something important:

The goal of zsh is not to be a ksh clone.  The goal of zsh (as far as I'm
concerned) is to be a powerful superset of sh that is especially good at
interactive use.  The ksh compatibility we have now is more a matter of
convenience than the result of explicitly trying to copy ksh.  Maintaining
ksh compatibility for common commands is a good idea, but I see no compelling
reason to copy every last detail of ksh.

Richard Coleman
coleman@math.gatech.edu



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [[ str == pat ]] ?
  1995-10-12 12:07 ` Zoltan Hidvegi
  1995-10-12 18:19   ` ksh compatibility Richard Coleman
@ 1995-10-12 20:36   ` Glenn Barry
  1995-10-13  4:32     ` Arnold D. Robbins
  1 sibling, 1 reply; 5+ messages in thread
From: Glenn Barry @ 1995-10-12 20:36 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: glenn, zsh-workers, Arnold D. Robbins


 Zoltan> 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...

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

 Zoltan> Could you post your ksh documentation?

Sure, it's the "KORN SHELL REFERENCE" card by arnold robbins for
Specialized Systems Consultants, Inc (Seattle, WA, USA) at
sales@ssc.com.  It describes both ksh88 and ksh93.  It's color coded
so the ksh93 stuff is in blue ... nicely done, btw.  Zsh could use one
of these ... richard, if you want to do one of these for zsh then
contact arnold (arnold@skeeve.atl.ga.us) and/or SSC at the above
address. (i have no biz interest in this, btw)

The card says

	string = pattern 
		true if string matches pattern 
		quote any part of pattern to treat 
			it as a string; *obsolete in ksh93*

	*string == pattern*
		*same as = (preferrred in ksh93)*

(coded *blue* for ksh93)
	
Arnold consulted with dave korn on the ref card so i bet it's correct
:).

Note the ksh with solaris 2.4 is ksh88i but if you have cde, then
dtksh is ksh93 w/motif extensions.

glenn





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [[ str == pat ]] ?
  1995-10-12 20:36   ` [[ str == pat ]] ? Glenn Barry
@ 1995-10-13  4:32     ` Arnold D. Robbins
  0 siblings, 0 replies; 5+ messages in thread
From: Arnold D. Robbins @ 1995-10-13  4:32 UTC (permalink / raw)
  To: Glenn Barry, Zoltan Hidvegi; +Cc: zsh-workers


>  Zoltan> My ksh manual from Solaris 5.4 (Last change: 3 Aug 1993) does
>  Zoltan> not mention this, but I tried the ksh here, and it accepted
>  Zoltan> the == syntax.

Many things that were not documented until ksh-93 made their way into the
minor ksh88 releases. ksh88i is pretty recent, so it's not suprising that
it's there. I bet if you try the ksh on Ultrix (pure original ksh88,
not even ksh88a) it won't be there.

The card that GB talks about documents things as being in both if they
were in the early ksh88 versions too, even if undocumented. E.g., the
$((...)) math syntax was in ksh88 from the start, but undocumented; since
it's there, the card has it in black (== both versions). cd -P and cd -L
are that way too. No other examples spring to mind.

I actually got ksh93, it's doc, and a draft of the new ksh book before it
was printed while working on the card. It took all of that to make the
card complete. It was a lot of work, but worth it.

There might be a market for a zsh ref card. If someone is seriously interested,
let me know, I can make the connections.

Arnold


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1995-10-13  5:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-10-12  5:42 [[ str == pat ]] ? Glenn Barry
1995-10-12 12:07 ` Zoltan Hidvegi
1995-10-12 18:19   ` ksh compatibility Richard Coleman
1995-10-12 20:36   ` [[ str == pat ]] ? Glenn Barry
1995-10-13  4:32     ` Arnold D. Robbins

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).