[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug/limitation in 'time'
From: |
Linda Walsh |
Subject: |
Re: Bug/limitation in 'time' |
Date: |
Mon, 18 Mar 2013 15:12:59 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
Chris Down wrote:
> On 2013-03-18 00:46, Linda Walsh wrote:
>> Bruce Dawson wrote:
>>> Chris Down pointed that out. My loop now looks like this -- portable (I
>>> believe) and fast:
>>>
>>> BashCount() {
>>> for (( i = $1 ; i > 0 ; i-- )); do
>>> :
>>> done
>>> echo Just did $1 iterations using bash math
>>> }
>> ----
>> To do the above, you'd want to pre-init
>
> There is no need to preinitialise the variable, I'm not sure why you think it
> is
> necessary.
the above pre-inits "i to $i" before the loop.
If you want to make the loop portable, it seems some variation on
while would be necessary, thus the need to pre-init the value to the
count before going into the while, maybe:
n=10;while [ $((n-=1)) != 0]; do echo $n;done
- Bug/limitation in 'time', Bruce Dawson, 2013/03/16
- Re: Bug/limitation in 'time', Chris Down, 2013/03/16
- RE: Bug/limitation in 'time', Bruce Dawson, 2013/03/17
- Re: Bug/limitation in 'time', Chris Down, 2013/03/17
- Re: Bug/limitation in 'time', Linda Walsh, 2013/03/17
- RE: Bug/limitation in 'time', Bruce Dawson, 2013/03/18
- RE: Bug/limitation in 'time', Chris F.A. Johnson, 2013/03/18
- Re: Bug/limitation in 'time', Jonathan Nieder, 2013/03/18
- Re: Bug/limitation in 'time', Linda Walsh, 2013/03/18
- Re: Bug/limitation in 'time', Chris Down, 2013/03/18
- Re: Bug/limitation in 'time',
Linda Walsh <=
Re: Bug/limitation in 'time', Chris F.A. Johnson, 2013/03/17
- RE: Bug/limitation in 'time', Bruce Dawson, 2013/03/16
- Re: Bug/limitation in 'time', Chris Down, 2013/03/16
- Re: Bug/limitation in 'time', Pierre Gaston, 2013/03/17
- RE: Bug/limitation in 'time', Bruce Dawson, 2013/03/17
- Re: Bug/limitation in 'time', Pierre Gaston, 2013/03/17
- Re: Bug/limitation in 'time', Bob Proulx, 2013/03/17
- Re: Bug/limitation in 'time', Pierre Gaston, 2013/03/17
Re: Bug/limitation in 'time', Hans J. Albertsson, 2013/03/17
Re: Bug/limitation in 'time', William Park, 2013/03/17