From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,4d8a7c59a6a24c3,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 2002-05-13 19:55:02 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: sms@antinode.org (Steven M. Schweda) Newsgroups: comp.unix.osf.osf1 Subject: /bin/sh bug? "$#" in function never zero? Date: 13 May 2002 19:55:02 -0700 Organization: http://groups.google.com/ Message-ID: <5722d1e1.0205131855.3f6402af@posting.google.com> NNTP-Posting-Host: 209.98.249.184 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1021344902 30696 127.0.0.1 (14 May 2002 02:55:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 14 May 2002 02:55:02 GMT Xref: archiver1.google.com comp.unix.osf.osf1:111 % cat arg.sh #!/bin/sh echo " argc = $#." echo " \$1 = >$1<." p_a() { echo " p_a. argc = $#." echo " p_a. \$1 = >$1<." } p_a "$@" Now, on Solaris (SunOS 4.1.4 or 5.7): % ./arg.sh argc = 0. $1 = ><. p_a. argc = 0. p_a. $1 = ><. While on Tru64 (5.1A): % uname -a OSF1 pxp.provis.com V5.1 1885 alpha % ./arg.sh argc = 0. <-----+ $1 = ><. | p_a. argc = 1. <-----+ p_a. $1 = ><. Add an argument, and all the zeros turn to ones, as expected. This quirk upsets some scripts I'd prefer not to have to change. Any wisdom? ------------------------------------------------------------------------ Steven M. Schweda (+1) 651-699-9818 (voice, home) 382 South Warwick Street (+1) 763-781-0308 (voice, work) Saint Paul MN 55105-2547 (+1) 763-781-0309 (facsimile, work) sms@antinode.org sms@provis.com (work)