pancake <pancake_AT_youterm.com> writes:
> On Thu, 2008-07-03 at 14:59 +0200, Oliver Heins wrote:
>> Hi Hugo.
>> | ~$ time (n=0; for i in {1000..1}; do n=$(($n+$i)); done; echo $n)
>>
>> I don't know if arithmetic evaluation is a bashism, but I think the
>> costs for using bc are quite high. However, I the let syntax (e.g.,
>> »let "n = n +i"«) should work with all posix-shells and therefore be
>> portable.
>
> its posix. the fork is also expensive, not only bc.
>
> 'let' is a bashism i think. shouldnt be used imho.
Perhaps I'm misguided by
http://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.baseadmn/doc/baseadmndita/korn_shell_arith_eval.htm
This site is about the korn shell, which is the standard posix shell.
There it's said, »The Korn shell or POSIX shell includes an alternative
form of the let command if only a single expression is to be evaluated.«
That alternative form is like ((x = x / 3)), and it's limited.
Best regards,
olli
-- http://www.sopos.org/olli/ GnuPG-Key: gpg --recv-keys 0x9A00D827 GnuPG-Fingerprint: F27A BA8C 1CFB B905 65A8 2544 0F07 B675 9A00 D827 Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.htmlReceived on Fri Jul 04 2008 - 11:26:10 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:53:19 UTC