Problem when using variable assignment, backticks in shell script
Fri Sep 1 02:16:00 GMT 2006
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.
# create a file called "temp" with text contents "liars"
echo liars > temp
# make 1000 attempts to reproduce the bug
for i in `seq 1 1000`
# use a backticked expression to assign the contents of "temp"
# to variable $x
x=`/usr/bin/cat < temp`;
if [[ $x != "liars" ]]
# if this code is reached, the variable assignment failed somehow
echo error attempt $i: \"$x\" is not the correct string \"liars\"
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin