*BSD News Article 34784


Return to BSD News archive

Xref: sserve comp.unix.user-friendly:2763 comp.unix.solaris:21492 comp.unix.questions:53994 comp.unix.programmer:19437 comp.unix.misc:13594 comp.unix.aux:15094 comp.unix.bsd:14662 comp.unix.aix:42859
Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!agate!ames!newsfeed.gsfc.nasa.gov!jagubox!jim
From: jim@jagubox.gsfc.nasa.gov (Jim Jagielski)
Newsgroups: comp.unix.user-friendly,comp.unix.solaris,comp.unix.questions,comp.unix.programmer,comp.unix.misc,comp.unix.aux,comp.unix.bsd,comp.unix.aix
Subject: Re: Xtree for Unix!?
Date: 22 Aug 94 16:35:52 GMT
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
Lines: 33
Distribution: inet
Message-ID: <3527@jagubox.gsfc.nasa.gov>
References: <Cuo63D.BE1@zimmer.CSUFresno.EDU> <331hnd$8r@spock.isar.muc.de> <332ftf$n5j@usenet.ins.cwru.edu> <id.5Z8C1.49B@nmti.com> <33ag2f$a0u@usenet.INS.CWRU.Edu>
Reply-To: jim@jagubox.gsfc.nasa.gov (Jim Jagielski)
NNTP-Posting-Host: jagubox.gsfc.nasa.gov
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

chet@odin.INS.CWRU.Edu (Chet Ramey) writes:

>In article <id.5Z8C1.49B@nmti.com>, Peter da Silva <peter@nmti.com> wrote:
>>In article <332ftf$n5j@usenet.ins.cwru.edu>,
>>Chet Ramey <chet@odin.INS.CWRU.Edu> wrote:
>>> Posix.2 says the args that follow `string' in `-c string' should become
>>> arguments $0...$N, not $1...$N, and this is what bash does.  Your program
>>> seems to be depending on a quirk of the BSD/386 /bin/sh. 
>>
>>Then POSIX.2 is broken. In every other context $0 is the program or function
>>name and $1..$N are the arguments.

>Please.  Posix.2 followed existing practice in this area.  Traditional
>/bin/sh and ksh do the same thing.

I hope you don't mean that 'sh' and 'ksh' use $0 as the 1st parameter
to a script or function, because that's not true.

$0 is the name of the script/function/command used to invoke it.
$1 is the 1st parameter/argument, etc...

Try this:
   $ cat tester
   echo $0 $1 $2
   $ ./tester foo bar
   ./tester foo bar

-- 
#include <std/disclaimer.h>
  |     Jim Jagielski      |  jim@jagubox.gsfc.nasa.gov  |  V: 301 286-5964  |
  | NASA/GSFC, Code 734.4  |     Greenbelt, MD 20771     |  F: 301 286-1719  |
                       <<  I want my TWO DOLLARS !!  >>
                                   --   The paperboy