Perl question
Bill Vermillion
fp at wjv.com
Thu Jun 17 13:53:37 PDT 2004
On Thu, Jun 17, 2004 at 01:50:12PM -0700, Steven Waters thus spoke:
> So I am assuming that, #/usr/bin perl -T is ignored.
> but, #!/usr/bin/perl -T is not?
Don't make assumptions they will get you into trouble every time.
Unix systems interpret files by 'magic numbers' the first few
characters of a file - they don't need the extensions that are
used to tell you what the file type is as in the MS world.
>From the shell man page you would see this: [edited down]
When a normal program is executed, the shell runs the program,
passing the arguments and the environment to the program. If
the program is not a normal executable file (i.e. if it does
not begin with the "magic number" whose ASCII representation
is "#!", resulting in an ENOEXEC return value from execve(2))
the shell will interpret the program in a subshell. The child
shell will reinitialize itself in this case, so that the effect
will be as if a new shell had been invoked to handle the ad-hoc
shell script, except that the location of hashed commands
located in the parent shell will be remembered by the child.
The magic number is used by the 'file' command to tell you what
kind of file it is.
To test just copy any file over to a new name and remove the !.
File will then tell you the file without the ! is ASCII text, but
the one with the ! is a shell script.
Bill
--
Bill Vermillion - bv @ wjv . com
More information about the Filepro-list
mailing list