help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Executing an empty file. Bug or feature?


From: Pierre Gaston
Subject: Re: [Help-bash] Executing an empty file. Bug or feature?
Date: Fri, 27 Mar 2015 13:42:07 +0200

On Fri, Mar 27, 2015 at 12:59 PM, Ricardo Ribalda Delgado <
address@hidden> wrote:

> Hello
>
> A friend of mine has found this behaviour from bash that is a bit weird.
>
>
> If you try to execute an empty file, it returns 0.
>
> address@hidden:/tmp$ touch empty
> address@hidden:/tmp$ chmod a+x empty
> address@hidden:/tmp$ ./empty
> address@hidden:/tmp$ echo $?
> 0
>
> execve() on the other hands returns -1 ENOEXEC
>
> address@hidden:/tmp$ strace -f ./empty
> execve("./empty", ["./empty"], [/* 40 vars */]) = -1 ENOEXEC (Exec format
> error)
> write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format
> error
> ) = 32
> exit_group(1)                           = ?
> +++ exited with 1 +++
>
>
> Is this behaviour expected or is a bug ?
>
>
> Regards!
>
>
>
> --
> Ricardo Ribalda
>
>
It is expected the manual says under "COMMAND EXECUTION":

"If  this  execution fails because the file is not in executable format,
and the file is not a directory, it is assumed to be a shell script, a file
containing shell commands.  A subshell is spawned to execute it. "

and under "ARGUMENTS"

"If no commands are  executed,  the  exit  status  is  0."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]