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 To: cygwin AT cygwin DOT com Date: Thu, 31 Aug 2006 20:16:03 -0600 (MDT) CC: Jim Easton X-Mailer: ELM [version 2.4ME+ PL66 (25)] Message-Id: X-IsSubscribed: yes 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 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/