Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!seismo!lll-crg!lll-lcc!vecpyr!amd!pesnta!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix Subject: Re: KSH substring function (is it on your system?) Message-ID: <3002@sun.uucp> Date: Sun, 17-Nov-85 15:20:30 EST Article-I.D.: sun.3002 Posted: Sun Nov 17 15:20:30 1985 Date-Received: Wed, 20-Nov-85 08:01:23 EST References: <121@rruxc.UUCP> <9@pixutl.UUCP> <813@whuxl.UUCP> Organization: Sun Microsystems, Inc. Lines: 48 > > As long as we're talking about 'substring', 'expr' has a 'substr' option > > that used to be documented in V6. > > ... > > 'expr' also has 'match', 'lentgh', and 'index' options that are not > > documented any longer. Anyone knows why? > > The ":" operator of expr now handles all of these cases (I've never > heard of "index"; what does it do?): V6? *V6?* I don't remember any "expr" command in V6; the main use of "expr" is between backquotes in the shell, and the V6 shell didn't have backquotes (alas). V7's "expr" had them, as did S3's; neither documented them. They disappeared in S5; the reason is, to quote Sun's manual page for "expr" which *does* document them: BUGS Note that the "match", "substr", "length", and "index" operators cannot themselves be used as ordinary strings. That is, the expression: tutorial% expr index expurgatorious length syntax error tutorial% generates the 'syntax error' message as shown instead of the value 1 as you might expect. ("tutorial%" is a shell prompt in the above example). "index" is documented there as: index "string" "character-list" reports the first position in "string" at which any one of the characters in "character-list" matches a character in "string". Note that, just like the V7/4.xBSD "index" function, this is *not* the same as the PL/I "index" function. (One reason why I approve of the renaming of "index" to "strchr" in S3/S5.) > -- old -- -- new -- > expr match string regexp expr string : regexp > ... "old" and "new" are somewhat misnomers here; all versions of "expr" since V7's support the "new" method as well as the "old" one. Guy Harris