Change the executing of a 0-byte file to be an error...

Harti Brandt hartmut.brandt at dlr.de
Fri Jun 10 11:37:28 GMT 2005


On Fri, 10 Jun 2005, Wartan Hachaturow wrote:

WH>On 6/10/05, Garance A Drosihn <drosih at rpi.edu> wrote:
WH>
WH>> error?  I read through a few likely pages in SUSv3, and it looked
WH>> like the behavior for executing an 0-byte file is not explicitly
WH>> defined.  Of course, it might be that I was simply looking in the
WH>> wrong part of the standard.
WH>
WH>To quote SUSv3's Shell and Utilities:
WH>"If the execve() function fails due to an error equivalent to the
WH>[ENOEXEC] error  defined in the System Interfaces volume of IEEE Std
WH>1003.1-2001, the shell shall execute a command equivalent to having a
WH>shell invoked with the command name as its first operand, with any
WH>remaining arguments passed to the new shell. If the executable file is
WH>not a text file, the shell may bypass this command execution. In this
WH>case, it shall write an error message, and shall return an exit status
WH>of 126."
WH>
WH>So it is merely an empty script execution. The kernel reports a failure, as it
WH>should.

Well, according to Posix an empty file is not a text file ('A file that 
contains characters organized in one or more lines.'). The 'may' above 
allows both behaviours for this case.

harti


More information about the freebsd-standards mailing list