Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!srhqla!quad1!ttidca!paulb From: paulb@ttidca.TTI.COM (Paul Blumstein) Newsgroups: comp.unix.questions Subject: Re: Another sed question. Message-ID: <8249@ttidca.TTI.COM> Date: 6 Dec 89 21:49:55 GMT References: <37091@ames.arc.nasa.gov> <4694@pinas.cs.vu.nl> <1989Dec5.112101.15906@gdt.bath.ac.uk> Reply-To: paulb@ncc1701.tti.com (Paul Blumstein) Organization: DAM: Mothers Against Dyslexia Lines: 29 In article <1989Dec5.112101.15906@gdt.bath.ac.uk> exspes@gdr.bath.ac.uk (P E Smee) writes: +In article <4694@pinas.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: +>Probably: +> +> #!/bin/sed 1d +> +> +>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@ttidca.TTI.COM DISCLAIMER: Everything & everyone is hereby disclaimed!