delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/28/19:57:22

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
X-Lotus-FromDomain: JPMORGAN AT SMTP
From: "Noel L Yap" <yap_noel AT jpmorgan DOT com>
To: cygwin AT sources DOT redhat DOT com
Message-ID: <8525692A.00642773.00@nyc-ntgw-n01.ny.jpmorgan.com>
Date: Fri, 28 Jul 2000 14:13:58 -0400
Subject: Re: shell script bug
Mime-Version: 1.0




cgf AT cygnus DOT com on 2000.07.28 12:57:49
>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.

Why?  From what I've read in "Unix Shells by Example" on page 259:
$@   Means the same as $*, except when enclosed in double quotes.  BTW, my
command line was:
./asdf.sh "a b" 'c d' e\ f g h

>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.

I agree, but I'm not seeing that behaviour.

Noel




This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.


--
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