Re: CASE error in script file

2006-11-09 Thread Jim Easton
Hi Eric,

08 Nov 2006 Eric Blake wrote:
...
 Consider upgrading - we're at cygwin 1.5.21 and bash 3.1 (or
 experimentally, 3.2).  This list does not make it a habit to support older
 than the previous release, because of the bugs that have been fixed since.
 
  
  Is there a bash variable that controls such behaviour (I can't find one)
  or was there an upgrade in the interim?
 
 HAVE YOU NOT BEEN READING THE ARCHIVES?  This has been the hottest topic
 on this list _all month long_.
 http://cygwin.com/ml/cygwin-announce/2006-11/msg9.html

Actually, to be honest, no :-). Thanks for the pointer and I have
commented my .bashrc file to remind me when I eventually do get
around to upgrading.  Not that it will bother me personally because I
seldom run into DOS style files and never shell scripts. - I was just
curious and hoping to learn something.

It's no wonder I couldn't find the ignrc option - it doesn't exist in
my version.  :-)

Also, as per Larry Hall, it hurls on linux, solaris and I didn't try
any others.

Thanks again.

Jim Easton

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



CASE error in script file

2006-11-08 Thread Doug
Hello,
I am using Cygwin  1.5.21(0.156/4/2).I try to run the shell script called 
test.sh

case $1 in
1)
echo '1'
;;
2)
echo '2'
;;
*)
echo 'Dunno'
exit 1
esac

but i always get the following error

'/test.sh: line 1: syntax error near unexpected token `in
'/test.sh: line 1: `case $1 in

I can run the script successfully in a linux box.

Please help

Doug


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Shankar Unni

Doug wrote:


case $1 in


If $1 is undefined (i.e. you pass in no arguments), this line becomes

   case  in

which is incorrect syntax, of course. Answer: quote the $1.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Doug
Shankar Unni shankarunni at netscape.net writes:

 
 Doug wrote:
 
  case $1 in
 
 If $1 is undefined (i.e. you pass in no arguments), this line becomes
 
 case  in
 
 which is incorrect syntax, of course. Answer: quote the $1.
 
 


I did put the $1 in and it still gives me the same error

case $1 in
1)
echo '1'
;;
2)
echo '2'
;;
*)
echo 'Dunno'
exit 1;;
esac

'/test.sh: line 1: syntax error near unexpected token `in
'/test.sh: line 1: `case $1 in

Thanks


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread DePriest, Jason R.

On 11/8/06, Doug  wrote:

Hello,
I am using Cygwin  1.5.21(0.156/4/2).I try to run the shell script called 
test.sh
but i always get the following error

'/test.sh: line 1: syntax error near unexpected token `in
'/test.sh: line 1: `case $1 in


I am using Cygwin 1.5.21(0.156/4/2), too!

I just opened up vim from a bash prompt in an rxvt window, manually
typed in your script, saved it as test.sh and ran ./test.sh.

It printed out 'Dunno' because I didn't give it any options.

It worked fine.

If I convert the file to have DOS line endings instead of UNIX line
endings, I recreate your problem exactly!

I am too lazy to search the (recent) archives about the bash
controversy surrounding line endings, but that is your problem.

Run d2u on your script, and it should work fine.

Also, what editor did you use to create the script?  If it was
notepad, please slap yourself in the forehead and exclaim, d'oh!

-Jason

--
+ + + NO CARRIER

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Shankar Unni

Doug wrote:


I did put the $1 in and it still gives me the same error
case $1 in

'/test.sh: line 1: syntax error near unexpected token `in
'/test.sh: line 1: `case $1 in


Do you have a DOS CR in there? (shows up as ^M in vim?) See the many, 
many threads in here about bash handling of CRs.



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Doug
DePriest, Jason R. jrdepriest at gmail.com writes:

 
 I am too lazy to search the (recent) archives about the bash
 controversy surrounding line endings, but that is your problem.
 
 Run d2u on your script, and it should work fine.
 
 Also, what editor did you use to create the script?  If it was
 notepad, please slap yourself in the forehead and exclaim, d'oh!
 
 -Jason
 


No, I use gVim 7.0 to edit the file.
So do you think the problem is related to the damned windows '\r' character?
Thanks buddy

And btw, d2u solves the issue!!!


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Eric Blake
Shankar Unni shankarunni at netscape.net writes:

 
 Doug wrote:
 
  case $1 in
 
 If $1 is undefined (i.e. you pass in no arguments), this line becomes
 
 case  in
 
 which is incorrect syntax, of course. Answer: quote the $1.

Quit spreading misinformation.

POSIX requires that token parsing take place BEFORE parameter expansion.  It 
also states that the first argument to case does not undergo token splitting.  
So even if your parameter is empty or undefined, you already have a valid 
parse, so that is not the cause of the reported syntax error.  In fact, you are 
also adding fuel to the incorrect flame that the first token after case must be 
quoted.  NOT SO.  The test string only needs quoting if, without quoting, it 
would not be recognized as a single token in the grammar; the two characters $1 
form a single token, even if its expansion contains spaces, so quotes do 
absolutely nothing for you in this example.

Instead, the syntax error is caused by \r: in\r is a different token 
than in, and the second token after 'case' must be 'in' according to the bash 
grammar.  Because you used DOS line endings on a binary mount, the \r was 
interpreted literally, and was used as part of the third token; review the 
archives for why DOS line endings on binary mounts are bad.  Without \r, the 
original script is perfectly legal.

-- 
Eric Blake
volunteer cygwin bash maintainer



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Jim Easton
Hi,

8 Nov 2006 21:57:40 Doug wrote:
 I am using Cygwin  1.5.21(0.156/4/2)
 case $1 in
 1)
 echo '1'
 ;;
 2)
 echo '2'
 ;;
 *)
 echo 'Dunno'
 exit 1
 esac
 ...
 '/test.sh: line 1: syntax error near unexpected token `in
 '/test.sh: line 1: `case $1 in
 ...

8 Nov 2006 22:17:08 Jason DePriest wrote:
 I am using Cygwin 1.5.21(0.156/4/2), too!
 ...
 It worked fine.
 
 If I convert the file to have DOS line endings instead of UNIX line
 endings, I recreate your problem exactly!

Interesting:  When I do that it works fine in both cases, even when I
force a CR at the end of the line.  It appears as though when bash
sees the CR at the end of line it automatically deletes it.  Mind
you I am using an earlier version of cygwin;

CYGWIN_NT-5.1 1.5.19(0.150/4/2) 2006-01-20 13:28
and so presumably an earlier version of bash
GNU bash, version 3.00.16(14)-release (i686-pc-cygwin)

Is there a bash variable that controls such behaviour (I can't find one)
or was there an upgrade in the interim?

If so I can't honestly say that it's an improvement.

Jim Easton

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Easton on 11/8/2006 7:47 PM:
 Interesting:  When I do that it works fine in both cases, even when I
 force a CR at the end of the line.  It appears as though when bash
 sees the CR at the end of line it automatically deletes it.  Mind
 you I am using an earlier version of cygwin;
 
   CYGWIN_NT-5.1 1.5.19(0.150/4/2) 2006-01-20 13:28
 and so presumably an earlier version of bash
   GNU bash, version 3.00.16(14)-release (i686-pc-cygwin)

Consider upgrading - we're at cygwin 1.5.21 and bash 3.1 (or
experimentally, 3.2).  This list does not make it a habit to support older
than the previous release, because of the bugs that have been fixed since.

 
 Is there a bash variable that controls such behaviour (I can't find one)
 or was there an upgrade in the interim?

HAVE YOU NOT BEEN READING THE ARCHIVES?  This has been the hottest topic
on this list _all month long_.
http://cygwin.com/ml/cygwin-announce/2006-11/msg9.html

- --
Life is short - so eat dessert first!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFUp6f84KuGfSFAYARApo5AKCr1yKTkgQh/AkfyFOe59EKHN3s7ACdGM/e
dRx+ozswfxVbNY7J6oxPNIs=
=nBor
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Larry Hall (Cygwin)

On 11/08/2006, Doug wrote:

I can run the script successfully in a linux box.


It wouldn't run in it's current form on a Linux machine.  Bash on Linux
wouldn't understand DOS text files either.  You'd see the same complaints
on Linux.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 893-9889 - FAX
Holliston, MA 01746

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: CASE error in script file

2006-11-08 Thread Larry Hall (Cygwin)

On 11/08/2006, Doug wrote:

No, I use gVim 7.0 to edit the file.


Windows or Cygwin version?  Either way though, gvim will write files
in binary or text form.  You need to tell it what you want though.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 893-9889 - FAX
Holliston, MA 01746

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/