[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 28 Mar 2014 08:53:08 +0100
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2
The links you pointed me are great. They were exactly what I was looking
for. Thanks a lot.:-)
On 03/27/2014 06:32 PM, Greg Wooledge wrote:
On Thu, Mar 27, 2014 at 08:19:39AM -0700, esoj wrote:
I need to specify a variable path after #! but seems to me that bash can't
For example I need to specify the $HOME or ~ path as in:
This belongs on help-bash, not bug-bash. That said, you can't do this
directly with the shebang, because the kernel doesn't care about ~ or
$HOME. It just knows file paths.
(That bit in the manual about "the shell does it if the OS doesn't"
is just a fallback for some really strange systems. On almost any
system you are likely to use, the kernel handles the shebang, not bash.
In fact, bash would only be able to handle it if you were running the
program FROM bash in the first place.)
The typical workaround is to write some clever boilerplate code at the
top of the script which is interpreted a comment (or a no-op) in one
language, and a valid instruction (to reinvoke the program with a
different interpreter) in another language. In this case, you want the
shebang to be #!/bin/sh, and you want boilerplate code that invokes
the script under ~/bin/python when the script is run by /bin/sh, but
which does nothing when it's invoked by python.
I would imagine some Python FAQ has this somewhere... let's see what
Google turns up.
There, that's not bad. The first answer in the second URL is nice
- #!path, esoj, 2014/03/27
- Re: #!path, Greg Wooledge, 2014/03/27
- Re: #!path,
Jose Soares <=