| delorie.com/archives/browse.cgi | search |
| 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 |
| Date: | Mon, 08 Apr 2002 10:14:14 -0400 |
| From: | Evan Teran <emt3734 AT ritvax DOT rit DOT edu> |
| Subject: | question about local variables in bash for cygwin |
| To: | cygwin AT cygwin DOT com |
| Message-id: | <000601c1df07$aa056550$3f891581@proxy> |
| MIME-version: | 1.0 |
| X-MIMEOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000 |
| Importance: | Normal |
| X-Priority: | 3 (Normal) |
| X-MSMail-priority: | Normal |
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |