[ClusterLabs] ocf scripts shell and local variables

Dmitri Maziuk dmitri.maziuk at gmail.com
Wed Aug 31 11:39:22 EDT 2016


On 2016-08-31 03:59, Dejan Muhamedagic wrote:
> On Tue, Aug 30, 2016 at 12:32:36PM -0500, Dimitri Maziuk wrote:

>> I expect you're being deliberately obtuse.
>
> Not sure why do you think that

Because the point I was trying to make was that having shebang line say
#!/opt/swf/bin/bash
does not guarantee the script will actually be interpreted by 
/opt/swf/bin/bash. For example

> When a file is sourced, the "#!" line has no special meaning
> (apart from documenting purposes).

(sic) Or when

> I haven't read the code either, but it must be some of the
> exec(2) system calls.

it's execl("/bin/sh", "/bin/sh", "/script/file") instead of execl( 
"script/file', ...) directly.

(As an aside, I suspect the feature where exec(2) will run the loader 
which will read the magic and load an appropriate binfmt* kernel module, 
may well also be portable between "most" systems, just like "local" is 
portable to "most" shell. I don't think posix specifies anything more 
than "executable image" and that on a strictly posix-compliant system 
execl( "/my/script.sh", ... ) will fail. I am so old that I have a vague 
recollection it *had to be* execl("/bin/sh", "/bin/sh", "/script/file") 
back when I learned it. But this going even further OT.)

My point, again, was that solutions involving shebang lines are great as 
long as you can guarantee those shebang lines are being used on all 
supported platforms at all times. Sourcing findif.sh from IPAddr2 is 
proof by counter-example that they aren't and you can't.

Dima





More information about the Users mailing list