Am 10.09.2015 um 20:50 schrieb Ed Morton:
> On 9/10/2015 12:03 PM, Barry Margolin wrote:
>>
>> [...] The relevant standard (POSIX) explictly states that
>> the interpretation of files that begin with #! is undefined.
>>
>> But we're talking about terminology, not execution. So even if the
>> standard did say how these things are processed, it wouldn't answer the
>> question of how we should refer to them.
>>
>
> That would seem to be a significant problem. Without names for things
> it's hard to have a discussion about them and it's easy for confusion
> and misinterpretation to occur.
tl;dr
If you can run your script successfully as 'awk -f yourscript'
it's an awk program, if you can run it successfully as, say,
'sh yourscript' it's a shell program. In this respect the #!
is meaningless for terminology; it's at best an informal hint.
>
> [...]
>
> So, that's why I'm trying to get a definitive answer to "what is the
> correct term for that file" as it'd help me unravel my own confusion on
> the subject in genera and the best solution for the specific problem at
> hand.
I already said something about the command interpreting the file,
which constitutes what a file "is", beyond its inherent property
of being text. To try making that point more obvious try answering
the question what the files containing the subsequent code are:
#! /bin/awk -f should not be used, use /usr/local/bin/perl instead !#
BEGIN { print "Hello World!" }
#! /bin/awk -f should not be used, use /usr/local/bin/perl instead !#
print "Hello World!\n" unless (0);
a) if executed in non-Unix (say DOS) environment
b) if executed with/without - careful: meta information! - chmod +x on Unix
c) without execution flag and and explicit interpreter awk
d) without execution flag and and explicit interpreter perl
You should note that #! is an informal comment in the first place.
Whether it's a interpreter script depends on the OS and the file
system's meta-information (execute flag), but that is an operational
property, not a file property. And also no script language property.
Whatever the #! will define, you will not be able to run the second
program with awk, and you will be able to run the first program with
awk and with perl. As opposed to your "Hello World" sample you usually
you have enough code in a file to identify the language. So it boils
down to identify the underlying language and necessary interpreter -
indepentent of OS, and execute flags, and #! mechanism! If you can
run such code explicitly with awk it's an "awk program". The shebang
comment is irrelevant to identify the "file type" WRT terminology;
it may just be used in addition to explain that in certain context
with certain preconditions it helps to run the program with an OS
supported implicit interpreter mechanism. If you can run your script
successfully as 'awk -f yourscript' it's an awk program, if you can
run it successfully as, say, 'sh yourscript' it's a shell program.
As already said upthread: "It depends on how you call it, and which
programs can work with it (interprete/compile/process/... it)."
Janis
>
> Ed.