Nicolas Williams wrote:
> 
> On Fri, Oct 31, 2008 at 12:13:19PM -0700, David Powell wrote:
> > >> It's a small issue and the
> > >> proposed solution is well worth the time/effort.
> >
> >    It hasn't been made clear that the proposed solution is "well worth
> >    the time/effort".  For starters, I haven't seen a proposed solution,
> >    only a suggestion that ksh93 could eliminate a few uses of sed.
> 
> Also, it's possible to do amazing things with sh alone.
> 
> E.g., grep(1) can be approximated with:
> 
> shgrep () {
>         found=1
>         while read line
>         do
>                 case "$line" in
>                         *${1}*) found=0; echo "$line"; break;;
>                 esac
>         done < "$2"
> 
>         return $found
> }
> 
> Yes, it's an approximation, and it's not entirely safe (echo will
> interpret escape codes in its arguments).

Right... 
... for the log: ksh93 has builing "grep" functionality using the
~(G)pattern stuff, e.g.
[[ "$a" == ~(G)CDDL.*HEADER ]] && printf "match\n"
will compare the content of variable "a" against the "grep" pattern
"CDDL.*HEADER".

Similar stuff exists for "fgrep" (e.g. ~(F)pattern), "egrep" (e.g.
~(E)pattern), "perl" pattern (e.g. ~(P)pattern), shell pattern (e.g.
~(S)pattern) etc.. Additionally some modifiers are supported, e.g. "i"
will do case insenstive matching (e.g. ~(Gi)cddl.*HEADER or
~(Si)cddl*header) and left and right anchors (e.g. ~(El)pattern,
~(Er)pattern, ~(Elr)pattern etc.). Beyond that there are a compile of
other pattern operators, too (see ksh93(1)).

> >    Finally, while moving to ksh93 isn't a big deal, it is something else
> >    that consumers would need to do -- something that could be the one
> 
> While I really like ksh93, I do think that *requiring* these scripts to
> *all* be written in ksh93 is too much.

They don't need to be written _all_ in ksh93 but I would prefer that the
more complex scripts use ksh93 since these are usually affecting the
startup time and ksh93 will usually result in a very large performance
boost for such scripts (see Moinak's comments about "configure" scripts,
some of the scripts which need 2mins with the original Bourne shell run
with less than 10 seconds with ksh93).

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to