[OS X TeX] can't find files in /usr/local/tetex/bin/

Stefan Walsen stefan at walsen.net
Fri Apr 9 07:04:16 EDT 2004


Justin Walker wrote:
> On Apr 8, 2004, at 17:06, Stefan Walsen wrote:
>> That depends on several things:
>> If the first line is "#!/bin/bash", it'll be run by bash and 
>> everything will work fine.
> That is true; what I was pointing out is that you (or, at least, I) 
> don't know that, within the environment where that shell script is 
> executing, the variable SHELL will be set to '/bin/bash', or perhaps, 
> the environment inherits the setting of SHELL from the shell that 
> invoked the shell script in the first place.

Ah, OK. That's definitely not what I thought we were talking about :)

The value of $SHELL is indeed inherited from the parent process.
So when somewhere SHELL is set to '/bin/bash', and afterwards you call 
"tcsh <script>", SHELL will still be '/bin/bash'. BUT from inside your 
script, $0 also doesn't give you the answer you're looking for, as that 
will be the name of the script itself unless you called it with "source 
<script>".

> My main point is that trying to nail down the shell that you are 
> executing under is tricky.  Relying on SHELL is probably not a good 
> thing.  I don't, however, have a definitive answer.
> [...]
> 'bash' and 'tcsh' often masquerade as 'sh' and 'csh', respectively, so 
> this [echo $0] check isn't definitive either.

Of course, and as I just said, it doesn't work at all from inside a 
script. The only reasonable way to make sure what shell you are 
executing under _as a script_ is to explicitly state which one you want 
it to be by putting the "#!"-line in front of it.

Whether you get "the real sh" or just a symlink to bash doesn't matter 
in this case, because bash behaves just as sh would when called with 
this name. I don't know about tcsh, but i'd expect the same.

Stefan
-----------------------------------------------------
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the MacOSX-TeX mailing list