Frank Peters posted on Tue, 02 Jul 2013 12:54:54 -0400 as excerpted:

(Thanks for the insight into your more direct boot scripts.  I've done 
that with some things here, including with my own custom suspend/
hibernate scripts, but not with my bootscripts.)

> So what does the "#!" option accomplish?  Does it allow the kernel to
> effect redirection based on "#!?"

Yes.

> This should only be necessary if bash
> itself is not invoked, but in boot-up based on init and inittab, bash, I
> believe, is automatically invoked for all scripts.  But yet the agetty
> program, after boot-up is essentially complete, fails to execute the
> bash script in its parameter list.  At this point is it agetty, or the
> kernel, that is responsible for executing the autologin script?

Given your customized setup I don't know for sure, but I can make an 
educated guess that at the point that breaks in that setup, the already 
running bootscript invokes a second script directly by name, as if it 
were a binary.  With the kernel shebang option, that works as long as 
that second script is set executable.  But without the kernel shebang 
option, it fails.

The alternative that WOULD work, would be to call that second script 
using an indirect invocation with bash as the command executed directly 
by the kernel and the second script as a parameter to it, like so:

bash (bash options) /path/to/script (script arguments)

By doing it that way, the kernel invokes bash, which knows how to handle 
it, and can (I believe) in fact handle #!/bin/perl and other foreign 
interpreter shebangs as well, instead of the kernel attempting to execute 
the script directly, and failing if the kernel doesn't have shebang 
support loaded.

(Altho it'll be obvious to some, it's also worth mentioning that with 
indirect script invocation via direct invocation of the interpreter, 
feeding it the script by commandline, the script itself no longer needs 
to have executable permissions, since bash is perfectly happy to execute 
any file it is fed on the commandline as long as it can read it, while 
the kernel refuses to execute files without the executable bit set.)

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


Reply via email to