On Fri, 26 Nov 2010 11:40:32 -0500 (EST), Joao Ferreira wrote:
> seems that $0 simply contains the program being run and not the
> interpreter that is running it...

Hmm.  You're right.

   echo $0

works at a shell prompt, but not within a script.  I tried it
within a script, sort of, by sourcing it.  For example,

   . my_script

and it seems to work that way, but not when the script is invoked
by name as a command.  So far,

   ls -Al /proc/$$/exe

seems to be the best suggestion, but then of course you'll have
to parse the output.

When I'm writing scripts, I try to use the "least common denominator"
approach.  In other words, I use code that works with any shell
if I can.  If I really need to make use of a feature that only
works in one particular shell (usually bash), I just force bash
to be used by the special comment in line 1:

   #!/bin/bash

And then I know it will always be run by bash, regardless of which
shell is the default on the system.

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/28512199.657528.1290793315750.javamail.r...@md01.wow.synacor.com

Reply via email to