Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!umd5!uvaarpa!mer6g From: mer6g@uvaarpa.virginia.edu (Marc E. Rouleau) Newsgroups: comp.sources.d Subject: Re: Perl: Hacking The !# Simulation Message-ID: <75@uvaarpa.virginia.edu> Date: 2 May 88 15:01:23 GMT References: <67@uvaarpa.virginia.edu> <394@dsinc.UUCP> Reply-To: mer6g@uvaarpa.Virginia.EDU (Marc E. Rouleau) Organization: University of Virginia, Charlottesville Lines: 36 >>eval "exec /bin/perl `/usr/local/ksh -c \"whence $0\"` $*" >> if $running_via_sh; >> >>The only folks still left in the cold are those who have only the Bourne >>shell (sh(1)). > >Even those are not left out in the cold, they can use the type internal >command which finds the executable. But "type" prints its output in "whence -v" format, so further processing with something like expr(1) would be necessary. Also, not all sh's have a builtin "type": our 4.3bsd Microvax and 4.3bsd Vax 11/780 are examples. (Now I know that 4.3bsd machines are lucky enough to have the #! hack and therefore need not be considered in an all-inclusive solution to this problem--I'm just wondering if _all_ sh's on machines which do _not_ have the #! hack do indeed have the "type" builtin ...) >Now we need a way to have it automatically determine the shell type and use >the appropriate command if needed. I think this is all becoming much too complicated. The original idea is relatively elegant and simple, and, in the absence of #! for System V, it seems like the next best thing; _however_, I really think the path-searching complexity oughta be implemented within perl. What if we could do something like this: eval "exec /bin/perl -S $0 $*" if $running_via_sh; The -S switch would cause the script file to be searched for either using an algorithm implemented within perl (best case) or else by running a program (ksh, csh, sh) the path to which is configurable and compiled in (acceptable case). -- Marc Rouleau