Dan Price wrote:
> On Thu 12 Mar 2009 at 06:13PM, Jerry Jelinek wrote:
> > I updated the webrev at:
> >
> > http://cr.opensolaris.org/~gjelinek/webrev.7304/
> >
> > in case anyone else wants to check it out.
> 
> With ksh, I've usually used [[ $? -ne 0 ]] instead of (( )), which seems to
> mostly be about actually doing arithmetic.

Erm... four issues:
1. If you only compare numbers (( )) arithemtric expressions should be
preferred. Using [[ ]] forces the shell to convert the internal value (a
|long long|) to a string, travel lots of expansion code for the string
and finally pass it to the "test" builtin which converts it back to a
number - which is IMO an overkill.
2. See
http://www.opensolaris.org/os/project/shell/shellstyle/#compare_exit_code_using_math
3. The POSIX standard explicitly supports comparisations via arithemtric
expressions to make this more efficient than the old "test"
builtin+operator (= [ expr ])
4. The "-ne" operator is depreciated within [[ ]]:
-- snip --
$ ksh93 -n '[[ $? -ne 0
]]'                                                                             
           
ksh93: warning: line 1: -ne within [[...]] obsolete, use ((...))
-- snip --

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to