bug-dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-dejagnu] Remote file exists bug


From: Simon Marchi
Subject: [Bug-dejagnu] Remote file exists bug
Date: Mon, 11 Jan 2016 16:04:34 -0500

Hi,

I tried using:

    remote_file target exists $file

with a remote target, and noticed it would always return true,
regardless if the file actually exists.  The test done to implement
this is the following (found at remote.exp:769):

    set status [remote_exec $dest "sh -c 'exit `\[ -f $file \]`'"]

The intent of the code is clear: it expects "[ -f $file ]" to output 1
or 0, depending on if the file actually exists.  That would give "exit
1" or "exit 0", giving us the result of our test.

However, the [ operator does not actually output anything, it returns
1 or 0 as its exit code.  So the outcome is always simply "exit",
which is equivalent to "exit 0", which is always true.  As an
alternative, I suggest calling the "test" utility (which is present on
all unixes I know about) and use its exit code directly:

    set status [remote_exec $dest "test -f $file"]

I attached a  patch that implements this change.  What do you think?

Thanks

Simon

Attachment: 0001-Fix-remote-file-exists-check.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]