Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: #! magic number Message-ID: <7275@mimsy.UUCP> Date: Wed, 1-Jul-87 03:49:05 EDT Article-I.D.: mimsy.7275 Posted: Wed Jul 1 03:49:05 1987 Date-Received: Thu, 2-Jul-87 02:03:49 EDT References:> <2211@bunker.UUCP> <1097@mtune.ATT.COM> <4145@teddy.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 28 In article <4145@teddy.UUCP> jpn@teddy.UUCP (John P. Nelson) writes: >... I then noted that the #!/bin/awk line had a BLANK at the end of >the line. I have to assume that when the kernel sees the blank, >it inserts a "null" argument. No, for the kernel code that handles `#!' magic numbers is purposely extremely simple. It no longer requires exactly one blank in the right places (if indeed it ever did so), but it creates at most one `argv' argument. The call execl("bin/foo", "argv0", "argv1", (char *)0), where file foo begins with `#! /bin/awk -f ', becomes equivalent to execl("/bin/awk", "awk", "-f ", "bin/foo", "argv1", (char *)0). The original argv[0] simply vanishes. The script I gave earlier began #! /bin/awk { if (NR > 1) print } This passes the single argument `{ if (NR > 1) print }' to awk. The implementation is quite economical; it is most certainly *not* a full shell parser. If you require a full shell parser, you can begin your file with `#! /bin/sh'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chr EP