Re: #! syntax
On Mon, Feb 26, 2001 at 05:50:54PM +0100, Carel Fellinger wrote:
| On Mon, Feb 26, 2001 at 08:22:34AM -0800, Michael O'Brien wrote:
| > 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.
|
| You could consider:
|
| #!/usr/bin/env perl
|
| as more installs will have env in the same place.
|
This is the correct way to begin python scripts (I can't say how the
perl community feels) :
#!/usr/bin/env python
# python code here
The idea is that env knows where stuff on the current machine is, so
simply ask it for the interperter you want (python, perl, bash, etc).
On a tangent, is there a way to manually configure env as to program
locations? In particular, how can I have env on my cygwin
installation know where python is (Win32 python build)? For now I
have my python script in foo.py with a wrapper foo that does :
#!/bin/bash
python foo.py $*
-D
Reply to: