| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| X-Amavis-Alert: | BAD HEADER Improper folded header field made up entirely of whitespace (char 20 hex): Subject: ...iable assignment, backticks in shell script\n \n |
| Subject: | Re: Problem when using variable assignment, backticks in shell script |
| From: | Jim Easton <jim AT cs DOT ualberta DOT ca> |
| To: | cygwin AT cygwin DOT com |
| Date: | Thu, 31 Aug 2006 20:16:03 -0600 (MDT) |
| CC: | Jim Easton <jim AT cs DOT ualberta DOT ca> |
| X-Mailer: | ELM [version 2.4ME+ PL66 (25)] |
| Message-Id: | <S576525AbWIACQD/20060901021612Z+184@sunkay.cs.ualberta.ca> |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| 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,
Mon, 28 Aug 2006 Russell Silva wrote:
> I am having a problem using Cygwin, variable assignment, and backticks
> when shell scripting. Occasionally, variables assigned using a
> backticked expression are not properly assigned; they are left empty.
> The problem appears to be non-deterministic.
For what's it's worth I ran this script maybe a dozen times with no
hint of trouble.
HTH.
Jim
#!/bin/bash
# create a file called "temp" with text contents "liars"
rm temp
touch temp
echo liars > temp
# make 1000 attempts to reproduce the bug
for i in `seq 1 1000`
do
# use a backticked expression to assign the contents of "temp"
# to variable $x
x=`/usr/bin/cat < temp`;
if [[ $x != "liars" ]]
then
# if this code is reached, the variable assignment failed somehow
echo error attempt $i: \"$x\" is not the correct string \"liars\"
fi
done
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |