Bug 3943 - error in testing file of existence
Summary: error in testing file of existence
Status: RESOLVED INVALID
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.18.x
Hardware: Other Linux
: P5 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-01 10:35 UTC by mbr
Modified: 2011-07-02 23:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mbr 2011-07-01 10:35:26 UTC
The following script fails:

#!/bin/ash

FILE=

if [[ -e ${FILE} ]]
then
	echo "found file: \`${FILE}'"
else
	echo "did not found file: \`${FILE}'"
fi

The test is always true!! So it says: found file `'
Comment 1 Denys Vlasenko 2011-07-02 23:17:57 UTC
Not a bug: bash and coreutils do the same.

You should use

if [[ -e "${FILE}" ]]

instead.