Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <99B82AA9708ED0119B55006097125A00363EE4@ifk63.mach.uni-karlsruhe.de> From: Heribert Dahms To: "'Bob McGowan'" Cc: cygwin AT sourceware DOT cygnus DOT com Subject: RE: shell script bug Date: Fri, 28 Jul 2000 22:28:13 +0200 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1457.3) Content-Type: text/plain Hi, maybe ${1+"$@"} helps. Famous example for Tcl/Tk wrapper under Unix: #!/bin/sh # the following comment is continued in Tcl, but not in sh #\ exec tclsh "$0" ${1+"$@"} puts "Tcl script begins here" Bye, Heribert (heribert_dahms AT icon-gmbh DOT de) > -----Original Message----- > From: Bob McGowan [SMTP:rmcgowan AT veritas DOT com] > Sent: Friday, July 28, 2000 19:26 > To: cygwin AT sources DOT redhat DOT com > Cc: cygwin AT sourceware DOT cygnus DOT com > Subject: Re: shell script bug > > 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. > > -- > Bob McGowan > Staff Software Quality Engineer > VERITAS Software > rmcgowan AT veritas DOT com > > -- > Want to unsubscribe from this list? > Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com