From owner-freebsd-doc@FreeBSD.ORG Tue Jul 15 01:23:50 2008 Return-Path: Delivered-To: doc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4E5F106568D for ; Tue, 15 Jul 2008 01:23:50 +0000 (UTC) (envelope-from peter@taronga.com) Received: from apollo.taronga.com (apollo.scarydevil.com [67.88.77.145]) by mx1.freebsd.org (Postfix) with SMTP id B3CA08FC1F for ; Tue, 15 Jul 2008 01:23:50 +0000 (UTC) (envelope-from peter@taronga.com) Received: (qmail 65598 invoked from network); 15 Jul 2008 00:57:07 -0000 Received: from localhost.scarydevil.com (HELO monolith.in.taronga.com) (127.0.0.1) by localhost.scarydevil.com with SMTP; 15 Jul 2008 00:57:05 -0000 Received: from [10.0.0.67] (majora-wired.in.taronga.com [10.0.0.67]) by monolith.in.taronga.com (Postfix) with ESMTP id 88EB4A938 for ; Mon, 14 Jul 2008 19:57:05 -0500 (CDT) Mime-Version: 1.0 (Apple Message framework v753.1) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3046E1F6-F847-4A6E-953F-7FDD6F50CBE9@taronga.com> Content-Transfer-Encoding: 7bit From: Peter da Silva X-Face: LHo^``F^LL$JWUC~A2"8!$u8AqGt5fXHi]KMU)FM"[&S-?j+T]E9eHNKSHNc,mex)_r:g_% y'_oz%gCuym5MgYd?evhsT]GNpEyG}G<=OH:](^wdIJ!yR6q25[[XTop,aVDD_:8jYoK!{=Owk3::g xQqghV*p5D$ta4\; yN*)u!U%r>c{&tq})|}IFc*w!|2msXlL\'z,#{f\l]tAqAo6vfmWbdq[)VXB}w Date: Mon, 14 Jul 2008 14:47:02 -0500 To: doc@FreeBSD.org X-Mailer: Apple Mail (2.753.1) Cc: Subject: The origin of the "#!" hack and selecting the shell X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jul 2008 01:23:51 -0000 In I read: "Later, a hack was made for sh(1) to examine the first two characters, and if they were :\n, then it invoked the csh(1) shell instead (we believe SCO first made this hack)." I'm pretty sure that nobody ever used ":\n" to indicate the C shell. This hack originated at Berkeley, when the current version of UNIX was still V6. Before the Berkeley psh (Pascal shell) and csh (C shell) were developed, there wasn't any need for these hacks... there was only one shell and it was /bin/sh. The V6 shell used the ":" (label) command for comments, while csh used "#". The first character of the file was checked by csh(1) and if it was a pound sign it used csh to run the script, otherwise it defaulted to the bourne shell. The "#!" hack (treating the string "#!" as a 16-bit magic number) came later, and was derived from this hack. At one point a Comp Center admin (I won't mention who) went through all the shell scripts on all the Comp Center machines and made them start with a copyright notice that looked something like "# Copyright (C) YYYY Regents of the University of California" which had the effect of breaking all the scripts for anyone who was using the C shell. Anyway, this was all happening in 1978 and 1979, and the first Xenix ports didn't start sneaking out until 1982, so it's unlikely that SCO had done anything like this first. :)