delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/28/13:32:27

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: Chris Faylor <cgf AT cygnus DOT com>
Date: Fri, 28 Jul 2000 13:31:06 -0400
To: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: shell script bug
Message-ID: <20000728133106.A5378@cygnus.com>
Reply-To: cygwin AT sourceware DOT cygnus DOT com
Mail-Followup-To: cygwin AT sourceware DOT cygnus DOT com
References: <20000728163013 DOT 15552 DOT qmail AT web1306 DOT mail DOT yahoo DOT com> <20000728125749 DOT A5152 AT cygnus DOT com> <3981C218 DOT F7E5348A AT veritas DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.2i
In-Reply-To: <3981C218.F7E5348A@veritas.com>; from rmcgowan@veritas.com on Fri, Jul 28, 2000 at 10:25:44AM -0700

When I said "machines" I should have said "different UNIX systems".

cgf

On Fri, Jul 28, 2000 at 10:25:44AM -0700, Bob McGowan wrote:
>Interesting.  I just tried a different script to check the "$@" versus
>"$*" processing and did not see any problems with or differences in how
>the 3 shells handle them.  I'm running these by invoking the desired
>shell at the prompt:
>
>	$ shell ./script
>
>My script:
>
>###
># "$@" with no args should be "empty"
>
>checkat()
>{
>        echo $#
>}
>
>checkasterix()
>{
>        echo $#
>}
>
>checkat "$@"       # "empty"
>checkasterix "$*"  # null string
>###
>
>The output is consistently:
>0
>1
>when I invoke the script with no arguments.
>
>Chris Faylor wrote:
>> 
>> On Fri, Jul 28, 2000 at 09:30:13AM -0700, Noel Yap wrote:
>> >I have the following script asdf.sh:
>> >#!/bin/sh
>> >
>> >if [ $# = 1 ]
>> >then
>> >  for v in "$@"
>> >  do
>> >    echo $# should be 1
>> >    echo "$v"
>> >  done
>> >else
>> >  for v in "$@"
>> >  do
>> >    echo $# isn\'t be 1
>> >    ./asdf.sh "$v"
>> >  done
>> >fi
>> >
>> >Under bash, the output of the script is:
>> >5 isn't 1
>> >5 isn't 1
>> >5 isn't 1
>> >5 isn't 1
>> >5 isn't 1
>> >
>> >Under sh, there is no output.
>> 
>> ...which is what I'd expect.
>> 
>> I tried this on a couple of machines and the behavior is inconsistent.
>> Some print "0 isn't be 1" (sic) and some print nothing.
>> 
>> I would consider the triggering of the for-loop when there are no
>> arguments supplied to the shell script to be a bug.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019