question about local variables in bash for cygwin

Evan Teran emt3734@ritvax.isc.rit.edu
Mon Apr 8 07:15:00 GMT 2002


Hello I have cygwin installed on my WinXP box and am loving it.  However
I just noticed today that when I tried to use the local keyword in my
bash script it gives me the error "local: not found".  The script works
on a RedHat box as expected so I would think that this is a cygwin/bash
problem.  Perhaps I am missing something really obvious, I am really a
C/C++ programmer and for the most part am just toying with bash
scripting trying to make an example of a return statement for my
professor who for some reason doesn't know how they work :P.  So, any
response would be great.

Thank you.

Evan Teran

Here is my bash version:
$ bash --version
GNU bash, version 2.05a.0(3)-release (i686-pc-cygwin)
Copyright 2001 Free Software Foundation, Inc.

Here is my example scipt:
------------start cut------------
#!/bin/sh

mySum()
{
    local SUM=0
    for i in $*
    do
       # SUM=`expr $SUM + $i`
    done
    return $SUM
}

# main body

# call the function
mySum $*

# put the value returned into variable A
# $? contains the return value of the last command executed
A=$?

# print out our variable
echo $A
-------------end cut-------------




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list