[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Our Most Precious Resource: Programmer Time (was Re: long term goals)



Philip Brown <phil@bolthole.com> wrote:
>
> 1. Singleshot external programs, with internal stuff.
>   For example, in POSIX shell, instead of using
>   val=`expr $var1 + var2`

>   you can use the *built-in* math functions, to do
>     val=$(($var1 + $var2))

Agreed.

>   Similarly, replace
>      if [ xxx ]
>   with
>      if [[ xxx ]]

>   The first is EXTERNAL. the second is built-in to POSIX-sh

Nope, the first one is built-in to all the shells that I know of.  While
the second one is not defined by POSIX and not supported by ash.

> 2. replace step-by-step I/O with external functions
>   Funny how that seems to contradict, eh? :-)
>   But if you have a big old loop like
>     while true ; do
>        read xyz
>        set $xyz
>          do stuff with vars
>     done

>   it can often be speeded up drastically by rewriting that loop in AWK.
>   That's what awk is for.

Definitely.  Especially since read has to read(2) byte-by-byte.
-- 
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



Reply to: