Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 From: ericblake AT comcast DOT net (Eric Blake) To: yann DOT dubost AT capgemini DOT com, cygwin AT cygwin DOT com Cc: Yann Dubost Subject: Re: eval function not working anymore !? Date: Thu, 15 Sep 2005 15:39:38 +0000 Message-Id: <091520051539.175.432995BA0004CE76000000AF22007340760A050E040D0C079D0A@comcast.net> > > Hello, > > I have been using cygwin for several years now and I have several scripts > tant do not work anymore since I installed the latest release of cygwin > (doxnloaded last week). > The reason is the eval function that I use quite a lot in such ways as : eval is not a function, but a builtin. > > DOMAINE_LISTE="DOM1 DOM2 DOM3" > DOM1_MODULES='D1_M1 D1_M2" Well, I hope that was a copy-n-pasto, because otherwise it would never work with mismatched quotes. > DOM2_MODULES="D2_M1 D2_M2" > > for domain in $DOMAINE_LISTE > do > eval MODULES=$"${domain}_MODULES" > ... > done > > Before it was working fine, but now echo $MODULES returns "DOM1_MODULES" or > "DOM2_MODULES" instead of "D1_M1 D1_M2" "D2_M1 D2_M2" > > Have you experience such a change ? > Do you have an idea why ? Yes - sh is now bash, and bash has a POSIX-allowed extension where $" " has special meaning for purposes of string translation ($" is undefined by POSIX, and unimplemented by ash, so you were lucky before). > How can I work around this problem (another function to use ?) Option 1: Fix your shell script to use POSIX compliant expressions (basically, $" is non-portable in the first level of evaluation, so quote the $ so that the second level of evaluation will see the desired $DOM1_MODULES). Any of the following properly quotes the leading $ (and there are other ways, too): eval MODULES=\$"${domain}_MODULES" eval MODULES="\$${domain}_MODULES" eval MODULES='$'"${domain}"_MODULES Option 2: Disable the bash extension in your script: shopt -u extquote -- Eric Blake volunteer cygwin bash maintainer -- 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/