Reputation: 201
I'm trying to get a shell script running in Cygwin and in the cut down section I posted below it crashes out with an error that reads:
new.sh: line 8: syntax error near unexpected token `newline'
#!/bin/sh
set -eu
usage(){
echo "$(cat <<"EOF")"
sh new.sh <--repo REPO>+
--repo | -r <REPO_URL>
url of a repository to analyze
REQUIRES --repo OR --repo-file
--save-credentials | -s
save credentials (in plain text) after running
--help | -h
shows this message
EOF
}
There are no carriage returns causing this error message. It seems its as a result of the angle brackets <
and >
. After removing them, it later falls over on the (
and )
brackets.
Is this a code issue or a Cygwin issue? Can somebody suggest a fix?
Upvotes: 0
Views: 214
Reputation: 247220
Why echo "$(cat <<"EOF")"
? Simplify: cat <<'EOF'
Also, the terminating EOF cannot have preceding whitespace, unless you use <<-
and there are strictly tab characters to indent. http://www.gnu.org/software/bash/manual/bashref.html#Here-Documents
Upvotes: 2