X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <4B4FAB5D.4000106@bopp.net> Date: Thu, 14 Jan 2010 17:40:13 -0600 From: Jeremy Bopp User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Can't set variables in a while loop that is passed to the rest of the script. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 1/14/2010 5:23 PM, Damo, David wrote: > Hi, > > I have fixed the problem. It seems in cygwin it spawns a subshell even under bash. I used a for loop instead and everything worked nicely. > > for line in `sed 's/\$/^/g' $propfile` > do > nvpair=$(echo $line | awk -F"=" '{print $1,$2}') > set -- $nvpair > if [ ! "$1" = "" ]; then > eval "$1"=\"$2\" > fi > done Interesting. Your workaround should work fine as long as the propfile is not too large, I think. However, wouldn't it be easier to source a properly massaged version of propfile instead? sed 's/\$/^/g' $propfile | grep -v '^=' >$propfile.tmp . $propfile.tmp rm $propfile.tmp -Jeremy -- 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