:: Re: [DNG] Apparently Jessie has run…
Forside
Slet denne besked
Besvar denne besked
Skribent: Rainer Weikusat
Dato:  
Til: dng
Emne: Re: [DNG] Apparently Jessie has runit
Ian Zimmerman <itz@???> writes:
> On 2016-01-21 01:25 +0000, Rainer Weikusat wrote:
>
> Rainer> That's a LSB invention. It's a grotesque travesty as it uses
> Rainer> 'magic comments' to embed a declarative mini programming
> Rainer> language in an init script which is only ever used when
> Rainer> modifying the runlevel configuration. Comments are supposed to
> Rainer> be used for relatively short, free-style documentation embedded
> Rainer> in code, not for interpretation by programs.
>
> Ian> There's precedent for this - the magic shebang lines perl, tcl, guile
> Ian> etc. use to get their grubby hands on a script that is masquerading as a
> Ian> plain shell script.
>
> Rainer> The kernel uses #! as two-byte magic number to mean 'whatever follows
> Rainer> that is the interpreter supposed to interpret this file'[*]. It doesn't
> Rainer> execute scripts. Hence, it doesn't define 'scripting language syntax
> Rainer> elements'.
>
> To be clear, in the paragraph you've quoted I was _not_ talking about plain
> shebangs such as
>
> #! /usr/bin/perl -f
>
> #! /usr/bin/tclsh
>
> (although then I was, in the next paragraph which you haven't quoted).


I was specifically writing about using comment-syntax of programming
language A to embedd programming language B code into an 'A'
file. That's what I called 'a travesty' because of the double issue of
overloading comments with formal meaning and because the information is
of no use to someone looking at the installed script.

#! is an entirely different animal because the information is needed for
running the script, it's also useful to someone looking at the script
code as it documents which interpreter is supposed to execute it and
it's really a 16-byte number supposed to conform to a convention how
older UNIX(*) kernels detected that a file was indeed an executable and
the type of it. It presumably doubles up as 'shell comment' to be
somewhat portable to systems without this feature where the shell just
tries to execute anything the kernel cannot.

But the 'LSB headers' were designed from scratch.

> Rather, I had in mind the serious contortions scripts used to go to
> when, for some reason, they _didn't_ rely on the kernel for executing
> the interpreter. Even today, the perlrun(1) manpage half-recommends
> this:
>
>     #!/bin/sh
>     #! -*-perl-*-
>     eval 'exec perl -x -wS $0 ${1+"$@"}'
>         if 0;


That's a more complicated trick to run a Perl script transparently on a
system without #! and working around a few more historic issues. There
may even be situations where this is appropriate but unless such a
situation is actually encountered, I wouldn't even contemplate using
this: Just-in-case 'portability hacks' are just cruft.

Provided the construct is not used 'just in case', it's also excused by
the necessity to handle adverse circumstances.