www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
From: | "Damo, David" <David DOT Damo AT CIBC DOT com> |
To: | "Damo, David" <David DOT Damo AT CIBC DOT com>, |
"cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> | |
Date: | Thu, 14 Jan 2010 18:23:28 -0500 |
Subject: | RE: Can't set variables in a while loop that is passed to the rest of the script. |
Message-ID: | <EDF49EC9787F914CA157FF6927D65A88302633AB82@CBMCC-X7-MBX10.ad.cibc.com> |
MIME-Version: | 1.0 |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
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 |
Hi, I have fixed the problem. It seems in cygwin it spawns a subshell even unde= r bash. I used a for loop instead and everything worked nicely. for line in `sed 's/\$/^/g' $propfile` do nvpair=3D$(echo $line | awk -F"=3D" '{print $1,$2}') set -- $nvpair if [ ! "$1" =3D "" ]; then eval "$1"=3D\"$2\" fi done -----Original Message----- From: Damo, David=20 Sent: Thursday, January 14, 2010 5:40 PM To: 'cygwin AT cygwin DOT com' Subject: Can't set variables in a while loop that is passed to the rest of = the script. Hi, I had a script that worked on UNIX, but on Cygwin it does not work. When I = set a variable in a while loop I can't use it after the loop. However, this= worked in UNIX. Any ideas why? All variables set after the done command ar= e blank, but can be seen in the while loop. propfile=3D${SCRIPT_HOME}/${propfilename} sed 's/\$/^/g' $propfile | while read line do export david=3D"Hello" nvpair=3D$(echo $line | awk -F"=3D" '{print $1,$2}') set -- $nvpair if [ ! "$1" =3D "" ]; then eval "$1"=3D\"$2\" fi done echo $david echo "Setting siteminder_home" echo $siteminder_home Thanks, David -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |