bug-bash
[Top][All Lists]
Advanced

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

Re: odd error from bash exec binary on cmd line


From: Chet Ramey
Subject: Re: odd error from bash exec binary on cmd line
Date: Sun, 25 Mar 2018 17:25:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 3/24/18 3:31 PM, L A Walsh wrote:

> bash sleep 1
> 
> I get:
> 
> /usr/bin/sleep: /usr/bin/sleep: cannot execute binary file
> 
> ???
> Isn't it bash that cannot execute the binary file because
> it expected a script?

Think about what happens when you run a command like that. Bash sees
that it has an argument, which it assumes to be a script. It sets the
positional parameters and $0 accordingly. Posix and historical behavior
say that $0 gets set from the name of the script.

Then the shell attempts to open the file and read it. It discovers
the file is not a text file, and refuses to execute it, prefixing the
error message with $0 as it usually does.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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