From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 999 invoked by alias); 28 Jul 2011 23:20:13 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16148 Received: (qmail 5965 invoked from network); 28 Jul 2011 23:20:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=sN4A+PMPJmOZa2caavulXtuHoDMZzpON839KDDLYBnA=; b=mahYM6SGkapcSPx4wSKWdAUig+B/EEb8u4dsKTvfn3601hsQd3S11lBOAOoon7hwFg WE2Mjd2tDoZLtVl9KlNCXxNK+9D2zZae3CG6LLNC7KADg24Ge4MegszrFa4910J+IKcp eyxzF4TPDUHrUIWNwaUiB0ynmFpaBqTgkugYQ= MIME-Version: 1.0 From: TJ Luoma Date: Thu, 28 Jul 2011 18:55:47 -0400 Message-ID: Subject: how to refer to basename of $0 To: Zsh Users Content-Type: text/plain; charset=ISO-8859-1 I am trying to move a bunch of my scripts to zsh instead of bash because I'm starting to run into little differences in the way things are handled which are annoying, and I figured it made more sense to just learn one way rather than two. I have a ".source" file that I use to setup some functions and variables for use in my scripts, and one of the things it does it this: NAME=`basename $0` which, in bash, gives me the basename of the script. For example, if the script "foo.sh" read .source like this: . $HOME/.source and then I did echo "$NAME" it would give me foo.sh but in zsh I get zsh Is there a way for me to get the equivalent of `basename $0` when writing shell scripts in zsh? (I hope this is understandable. If not, please let me know and I'll try to rephrase.) thanks for your time TjL