From: Chet Ramey (chet@nike.ins.cwru.edu) Subject: Re: Execing perl? Newsgroups: gnu.bash.bug Date: 2001-07-11 12:04:27 PST > OK, this isn't a bug, and it's also something that you'd _think_ would > be so obvious it'd be right at the top of all the FAQs, etc... but I > can't find it, nor can I figure it out. > > The Perl docs (perlrun) say you can use this stanza to write a perl > script when you don't know where the perl runtime will be; something > like: > > #!/bin/sh -- # -*- perl -*- > eval 'exec perl -wS $0 ${1+"$@"}' > if $running_under_some_shell; > > This doesn't work if bash is /bin/sh; I get this error: > > /bin/sh: -- # -*-perl-*-: unrecognized option This really doesn't have anything to do with the shell, per se. The kernel is passing the rest of the line to /bin/sh as argv[1], and bash is attempting to open it as a shell script. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ( ``Discere est Dolere'' -- chet) Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/