Mail Archives: cygwin/2000/07/28/22:42:07
On Fri, Jul 28, 2000 at 02:13:58PM -0400, Noel L Yap wrote:
>
>
>
>
>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
Well, that clarifies things, but I certainly don't get "no output" in
this situation. I get:
$ asdf.sh "a b" 'c d' e\ f g h
5 isn't be 1
1 should be 1
a b
5 isn't be 1
1 should be 1
c d
5 isn't be 1
1 should be 1
e f
5 isn't be 1
1 should be 1
g
5 isn't be 1
1 should be 1
h
which is exactly what I expect.
If I just type './asdf.sh', I get no output at all, as expected.
>>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.
Then you must not be running the cygwin version of /bin/sh.
The standard cygwin /bin/sh is based on BSD's 'ash' and it
operates as I've indicated above.
cgf
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -