This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with shell script


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]