delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/28/02:08:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: behaviour of "for (( exp1; exp2; exp3 )); do COMMANDS; done"
References: <PHENJGDFMJPEBOBLGEMOCENMCBAA DOT peter DOT oosterlynck AT oracle DOT com>
From: Harald DOT Maier DOT BW AT t-online DOT de (Harald Maier)
Reply-To: Harald Maier <maierh AT myself DOT com>
Date: Wed, 28 May 2003 08:08:02 +0200
In-Reply-To: <PHENJGDFMJPEBOBLGEMOCENMCBAA.peter.oosterlynck@oracle.com> (Peter
Oosterlynck's message of "Tue, 27 May 2003 09:56:37 +0200")
Message-ID: <m3brxn38ot.fsf@ate.maierh>
User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)
MIME-Version: 1.0
X-Sender: 320041125923-0001 AT t-dialin DOT net

"Peter Oosterlynck" <peter DOT oosterlynck AT oracle DOT com> writes:

> When using a line like "for (( i=1 ; i<=5 ; i+=1 )); do echo $i;
> done" in a bash script one expects to get a list of figures ranging
> from 1 to 5 right?  I've never had problems with such constructs on
> my Linux machine but when doing this in a cygwin bash shell, then it
> works fine when typed in at the command line but fails with a syntax
> error "Bad for loop variable" when executed in a script.
>
> Where did I go wrong? Ideas anybody?

This works for me on all bash environments. Keep strong the syntax.

Harald

--- for example ---
#! /bin/bash

for (( i=1; $i < 10; i=$i+1)); do
  echo $i
done
-------------------




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019