bug-bash
[Top][All Lists]
Advanced

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

Re: Strange/incorrect behavior of a fake executable file


From: Ilkka Virta
Subject: Re: Strange/incorrect behavior of a fake executable file
Date: Wed, 14 Mar 2018 16:33:36 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 14.3. 14:43, Greg Wooledge wrote:
This is ONE of the reasons why you should never put "." into your $PATH.

Well, the script could just contain `./junk` or `$0` instead and it would probably work regardless of PATH. Probably just better not to write self-recursing scripts; nor to run scripts whose behaviour isn't known.

At least that was a linear fork-loop, which is likely easier to stop than the exponential kind you usually see as a fork bomb.

1) You do not provide a hash-bang (i.e. #!/bin/bash), which means that
/bin/sh will be used (

No, that's incorrect.  When bash tells the operating system to run
this program, the operating system will return ENOEXEC (Exec format
error).  Bash (and every other shell) will catch this and spawn a
child copy of itself to try to interpret the program as a script.

Bash runs the script itself, Zsh and Dash run /bin/sh .
In the end it does get interpreted as a shell script, in both cases.

https://unix.stackexchange.com/questions/373223/which-shell-interpreter-runs-a-script-with-no-shebang


--
Ilkka Virta / itvirta@iki.fi



reply via email to

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