From: sms@antinode.org (Steven M. Schweda)
Subject: /bin/sh bug? "$#" in function never zero?
Date: 13 May 2002 19:55:02 -0700 [thread overview]
Message-ID: <5722d1e1.0205131855.3f6402af@posting.google.com> (raw)
% 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)
reply other threads:[~2002-05-14 2:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox