Re: Strange/incorrect behavior of a fake executable file

2018-03-16 Thread Eduardo A . Bustamante López
On Wed, Mar 14, 2018 at 08:43:45AM -0400, Greg Wooledge wrote: > > 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

Re: Strange/incorrect behavior of a fake executable file

2018-03-14 Thread Vladimir Likic
Hi Eduardo (and all), I was actually not doing anything useful, just playing with bash. I've got so used to putting '#! /bin/bash' at the top of the file, that I've completely forgotten that bash will attempt to execute commands even without hash-bang. Compounded to that, intuitively, I didn't exp

Re: Strange/incorrect behavior of a fake executable file

2018-03-14 Thread Chet Ramey
On 3/14/18 4:02 PM, Eduardo Bustamante wrote: > On Tue, Mar 13, 2018 at 11:34 PM, Vladimir Likic wrote: >> Sorry, meant why is bash executing the file without hash-bang '#!' ? > > You can see the answer here: > http://git.savannah.gnu.org/cgit/bash.git/tree/execute_cmd.c?h=devel&id=bf5b8103d466f

Re: Strange/incorrect behavior of a fake executable file

2018-03-14 Thread Eduardo Bustamante
(I've added bug-bash again) On Tue, Mar 13, 2018 at 11:32 PM, Vladimir Likic wrote: > Thanks for the quick response! > Your are correct, "." was in PATH (my bad), an it's calling itself > recursively. That went into a spiral and crashed the computer (literally). > Why is bash actually executing

Re: Strange/incorrect behavior of a fake executable file

2018-03-14 Thread Ilkka Virta
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 script

Re: Strange/incorrect behavior of a fake executable file

2018-03-14 Thread Greg Wooledge
On Tue, Mar 13, 2018 at 10:29:22PM -0600, Eduardo Bustamante wrote: > On Tue, Mar 13, 2018 at 7:24 PM, Vladimir Likic wrote: > > Repeat-By: > > > > $ echo junk > junk > > $ chmod +x junk > > $./junk > > --> this completely destroys my system Only if you have "." in your $PATH (or a function named

Re: Strange/incorrect behavior of a fake executable file

2018-03-13 Thread Eduardo Bustamante
On Tue, Mar 13, 2018 at 7:24 PM, Vladimir Likic wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-lin