Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 5
    I don't think it is possible, zero byte file is a valid shell script. Commented Jan 30, 2020 at 13:08
  • 2
    ... but you can check its size before executing it and fail if the size is 0. Commented Jan 30, 2020 at 14:13
  • 2
    An empty executable file is a valid implementation of the true command. Do you want sh -c '' to return an error message or a non-zero exit code as well? Commented Jan 30, 2020 at 14:13
  • 1
    Why would you want to do that? Maybe there is another solution. Commented Jan 30, 2020 at 14:34
  • 4
    No. Trying to execute a zero size executable will fail with ENOEXEC.What you're seeing is a feature of your shell or utility, which will try to run an executable by passing it to /bin/sh (or interpreting it itself) in case of ENOEXEC. Of course, you're not telling what system, shell or utility you're using, and what exactly your problem is, because facts and details are too boring. Commented Jan 30, 2020 at 18:22