delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/07/25/08:29:22

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
Message-ID: <42E4DB17.9030101@byu.net>
Date: Mon, 25 Jul 2005 06:29:11 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Marek <mkierebi AT o2 DOT pl>
CC: cygwin AT cygwin DOT com
Subject: Re: Problem with shell script
References: <20050724191302 DOT 58251D10DB AT rekin6 DOT o2 DOT pl>
In-Reply-To: <20050724191302.58251D10DB@rekin6.o2.pl>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Marek on 7/24/2005 1:13 PM:
> When I put commands below in command line:
> i=1
> echo $i
> i=$(($i+1))
> echo $i
> 
> everything works well (i is incremented from 1 to 2), but when I run this as a shell script the result is:
> 1+1 instead of 2
> 
> How should I do incrementation in shell script?

It depends on what shell you are using.  Following these directions:

> Problem reports:       http://cygwin.com/problems.html

will give me a better idea what version of /bin/sh you have, and you
should also say whether you are using a #! line at the start of your
attempted script.  Bash can do arithmetic expansion as required by POSIX,
ash cannot.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net
volunteer cygwin bash maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC5NsX84KuGfSFAYARAt3ZAKCSy1jtaR3ZI0Ex66LwfLSY0qvulwCglADl
ROVzSiFB9eFVH6RA6+uzzGc=
=r5PS
-----END PGP SIGNATURE-----

--
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