bug-bash
[Top][All Lists]
Advanced

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

Re: Bug/limitation in 'time'


From: Chris F.A. Johnson
Subject: Re: Bug/limitation in 'time'
Date: Sun, 17 Mar 2013 01:50:11 -0400 (EDT)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

On Sun, 17 Mar 2013, William Park wrote:

On Sat, Mar 16, 2013 at 10:15:50PM -0400, Chris F.A. Johnson wrote:
On Sun, 17 Mar 2013, Chris Down wrote:
  ExprCount() {
      for (( i = $1 ; i > 0 ; i-- )); do
          :
      done
      echo "$1 iterations"
  }

   Or, in a POSIX-compliant manner:

ExprCount() {
  i=$1
  while [ $(( i -= 1 )) -ge 0 ]; do
    :
  done
  echo Just did $1 iterations using expr math
}

Are you saying that

   for (( ; ; ))

is not POSIX?

   Right.

   But $(( ... )) is POSIX.

--
   Chris F.A. Johnson, <http://cfajohnson.com/>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]