Another sed question.

Paul Blumstein paulb at ttidca.TTI.COM
Thu Dec 7 08:49:55 AEST 1989


In article <1989Dec5.112101.15906 at gdt.bath.ac.uk> exspes at gdr.bath.ac.uk (P E Smee) writes:
+In article <4694 at pinas.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
+>Probably:
+>
+>	#!/bin/sed 1d
+>	<the rest of the script>
+>
+>When you try to execute this script, the kernel opens it to find out what kind
+>of executable it is.  The header of a *binary* includes the size of the text,
+>data and bss segments etc..  This file, however, isn't a binary: it's an
+>EXECUTABLE shell script.  The kernel discovers the `#!' MAGIC NUMBER and takes
+>the following word as the real executable to start.  There may be 1 option
+
+Question is, is this #! trick actually documented anywhere?  I certainly can't
+find it in any obvious place in my FM's (mostly sysV and 4.2bsd).  If so,
+where?  Is it a 4.3bsd feature, or something?  (I see a quick 'mention in
+passing' in J.E.Lapin's 'Portable C and Unix System Programming', which
+seems to imply that it isn't -- portable, that is.)

Yes!  The documentation is hidden.  It is magic, isn't it?  While it is
tempting to say that a magician doesn't reveal secrets, I'll tell you if
you promise not to tell anyone else :-).  The man page for execve (section
2) is where to look.
=============================================================================
Paul Blumstein       | "The judicial system is very fast now that they've gotten
Citicorp/TTI         | rid of the lawyers" - Back to the Future 2 (in 2015 AD)
Santa Monica, CA     +-------------------------------------------------------
{philabs,csun,psivax}!ttidca!paulb  or  paulb at ttidca.TTI.COM
DISCLAIMER: Everything & everyone is hereby disclaimed!



More information about the Comp.unix.questions mailing list