On Thu, 29 Jan 2009, whitewall <thewhitew...@live.co.uk> wrote:
The text below is from a text file. If I type the commands line-by-line in the bash then the commands work as expected. If I save the commands in a text file and call the script I get the error message: ': not a valid identifier2: declare: 'Red ': not a valid identifier3: declare: 'Green
Two error messages.
#! /cygdrive/c/cygwin/bin/bash declare -i Red declare -i Green Red=10 Green=$Red+1 echo $Green exit 0
You have a carriage return at the end of each line. bash does NOT consider carriage return to be whitespace, dammit, so it is considered normal characters. So it things, for example, that you're declaring a variable named "Red\r", a four-character name, and it just doesn't allow carriage return in the variable name. The key to recognizing the situation is to see ': not a valid identifier2: declare: 'Red and recognize that there's a carriage return in the middle of the message. The opening ' is just before Red. Its matching closing ' is shown as the start of the line -- because carriage return causes the output display to return to the start of line. So - by default, created files in UNIX file format, not native Windows. - strip out the carriage returns from your existing script -- Tim McDaniel, t...@panix.com -- 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/