Skip to content

Commit

Permalink
python_arch: return "unknown" when file does not exist
Browse files Browse the repository at this point in the history
The `file` program follows POSIX as outlined here:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/file.html

Specifically, this part causes troubles:
If the file named by the file operand does not exist, cannot be read, or
the type of the file named by the file operand cannot be determined, this
shall not be considered an error that affects the exit status.

With older versions of `file` (that does not conform to POSIX), this
script will exit 0 with "unknown" as its output when "$1" does not exist.
But with recent releases (that conform to POSIX), this script will exit 1
and can break the build.

Have the script explicitly check for the existence of $1 and if it does
not exist, then runt he unknown logic like normal.

BUG=chromium:332547
TEST=ran python_arch.sh on bogus files with new & old `file` programs

Review URL: https://codereview.chromium.org/137433002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244778 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vapier@chromium.org committed Jan 14, 2014
1 parent 97b4f5e commit 42117cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build/linux/python_arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#

file_out=$(file --dereference "$1")
if [ $? -ne 0 ]; then
# The POSIX spec says that `file` should not exit(1) if the file does not
# exist, so do our own -e check to catch things.
if [ $? -ne 0 ] || [ ! -e "$1" ] ; then
echo unknown
exit 0
fi
Expand Down

0 comments on commit 42117cc

Please sign in to comment.