*BSD News Article 34990


Return to BSD News archive

Xref: sserve comp.unix.user-friendly:2792 comp.unix.solaris:21816 comp.unix.questions:54188 comp.unix.programmer:19565 comp.unix.misc:13655 comp.unix.aux:15186 comp.unix.bsd:14727 comp.unix.aix:43142
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!constellation!mimbres.cs.unm.edu!tesuque.cs.sandia.gov!lynx.unm.edu!jobone!news1.oakland.edu!news.nd.edu!spool.mu.edu!howland.reston.ans.net!usenet.ins.cwru.edu!odin!chet
From: chet@odin.INS.CWRU.Edu (Chet Ramey)
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: 23 Aug 1994 14:26:19 GMT
Organization: Information Network Services, Case Western Reserve University
Lines: 34
Distribution: inet
Message-ID: <33d0ub$103@usenet.INS.CWRU.Edu>
References: <Cuo63D.BE1@zimmer.CSUFresno.EDU> <id.5Z8C1.49B@nmti.com> <33ag2f$a0u@usenet.INS.CWRU.Edu> <3527@jagubox.gsfc.nasa.gov>
NNTP-Posting-Host: odin.ins.cwru.edu

In article <3527@jagubox.gsfc.nasa.gov>,
Jim Jagielski <jim@jagubox.gsfc.nasa.gov> wrote:
>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.

No.  I meant exactly what I said.  The first argument following `string'
in `-c string' becomes $0.  The rest of the arguments become $1..$N.

odin(2)$ /bin/sh -c 'echo $0' zero one two three
zero
odin(2)$ /bin/sh -c 'echo $1' zero one two three
one
odin(2)$ uname -a
SunOS odin 4.1.2 13 sun4m
-- 
"I believe every human has a finite number of heartbeats.  I don't intend
 to waste any of mine running around doing exercises." - Neil Armstrong

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu