amoffat/sh — pull request #189 by jquast (2014-05-05 05:43:52+00:00)
Title: sh.py should not try to execute a folder

Problem: sh attempts to execute folders because which(1) fails
to determine that although folders may have execute-bit
set, they are not executable by execv(3)-family calls

Symptom: such call is blocking, never returns (!)

Solution: check the target is a file (following symlinks).

Details: The internal which(1) clone will attempt to execute any
folder matching the Command issued. So, given the PATH of:

/usr/opt/bin/gcc <- directory
/usr/bin/gcc <- executable file

sh would attempt to execute the folder, /usr/opt/bin/gcc.

[ As executing a folder would cause sh to block indefinitely
(an unhandled OSError is thrown on exec), the test adds a ._path
value assertion first, which prevents this test from hanging when
the fix is un-applied. ]