Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!edcastle!aiai!aipna!awb From: awb@uk.ac.ed.aipna (Alan W Black) Newsgroups: comp.os.minix Subject: Re: test/[ solved; new question: executable scripts? Message-ID: Date: 30 Apr 91 10:15:36 GMT References: <1991Apr29.110459.25477@doe.utoronto.ca> <9818@star.cs.vu.nl> Sender: news@aipna.ed.ac.uk Organization: Dept of AI, Edinburgh University, UK Lines: 46 In-reply-to: jms@cs.vu.nl's message of 29 Apr 91 22:45:45 GMT In article <9818@star.cs.vu.nl> jms@cs.vu.nl (Jan-Mark) writes: #> [ other stuff deleted ] #> #> I am also interested in executable scripts. Right now, when I make a #> script executable, the kernel always seems to presume that it is for #> sh. I would like to have executable scripts like #> #> #! /usr/gnu/bin/gawk #> #> BEGIN { print "hello" } #> #> /bug/ { print "Oh no!" } #> #> END { print "bye" } #> #> If this script were called "buggy", and I chmod'd it to make it #> executable, I would expect it to run under gawk, but the kernel still #> gives it to sh (can't find BEGIN...). Any advice, or is this another #> incredible dumb question? To some kernels #! is a magicnumber. If a file has #! as first two bytes, the rest of the line is put into an array and used in an ``system ()'' call. So hack the kernel is you want this! But are you sure you DO want this, remember; small is ..... Jan-Mark. (:> jms (_) ========""====== The gnu shell Bash actually checks for #! in the file it is about to execute so this technique does work when using bash (available on request). This surprised me as I thought Minix wouldn't do this but then realised that I has been using #! in my shell scripts for ages and it always worked. On investigation I saw that bash could deal with this itself without any kernel change. (I'm sure this is the right thing for bash to do though :-) Alan Alan W Black 80 South Bridge, Edinburgh, UK Dept of Artificial Intelligence tel: (+44) -31 650 2713 University of Edinburgh email: awb@ed.ac.uk