5 ms·
AFAICS some other interpreters, perl, python, ruby, tcl are happy to return a 0 exit code if invoked on an empty file.
by nonrandomstring 5y ago
AFAICS some other interpreters, perl, python, ruby, tcl are happy to
return a 0 exit code if invoked on an empty file.
- kayodelycaon 5y agoPretty much. They ran all the code that was in the file without errors.
- remram 5y agoEmpty files are common in Python: a __init__.py is required (or was) to mark a directory as a Python package, allowing its content to be imported.
- deathanatos 5y agoThere is a bit of a difference to me between the behavior described in the article (directly executing with ./foo) and "sh foo" or "python foo". In the former case, I would have expected a shebang to be needed, so that execv(2) would know what to execute (as it needs some magic bytes to determine what loader to use, or whether to treat it as a script, and I didn't think it had a fallback). (And I'm right… in a sense. The actual behavior is more complex & more horrifying, and covered in other comments.)