Path: utzoo!attcan!uunet!steinmetz!davidsen
From: davidsen@steinmetz.ge.com (William E. Davidsen Jr)
Newsgroups: comp.unix.questions
Subject: Re: argv[0] in shellscript?
Message-ID: <11114@steinmetz.ge.com>
Date: 6 Jun 88 18:15:56 GMT
References: <1813@stpstn.UUCP>
Reply-To: davidsen@crdos1.UUCP (bill davidsen)
Organization: General Electric CRD, Schenectady, NY
Lines: 21

In article <1813@stpstn.UUCP> aad@stpstn.UUCP (Anthony A. Datri) writes:
| 
| I want to write a script that will have multiple links to it, and be
| able to tell what name it was invoked with.  Ideas?

  How about $0? That's the name of the called program.  Watch out if you
have a full pathname (ie.  $0 = foo/something).  In that case use a case
to strip the leading name, like:

  case "$0" in
  foo | */foo)
    echo "Name is foo";;
  mumbl | */mumbl)
    echo "Name is mumbl";;
  *)
    echo "Name is wrong!";exit 1;;
  esac
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me