[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: #! syntax

"Michael O'Brien" <mobrien@pixar.com> writes:

> Hola~
> Is there any way to have a #! syntax that will conditionally run a
> interpreter based on a set of fallback locations?
> For example, we have a perl install in /dir/bin/perl. However, if
> you are at a non-work machine (ie, at home), you may not have a
> /dir/bin/perl. So, I'd like to have a script that will first try
> /dir/bin/perl, then if that doesn't exist, tries /usr/bin/perl.

Hmm, I don't know of any way to do this using the #! syntax, but you
could use install scripts or a shell wrapper to get this same
functionality.  For instance, you could ship the perl script without
the #!/path/to/perl line and have your install makefile find perl and
insert the correct line into the script.  Or, you could do something
like the following:


PERL=`which perl`

`$PERL /path/to/perl/script`


Reply to: