Bash and functions
-
I'm doing something terribly wrong and when I do I'll but until then I'm :
functiontest.sh:
function() { echo hi } function;
cmd:
$ bash functiontest.sh functiontest.sh: line 1: syntax error near unexpected token `(' functiontest.sh: line 1: `function() {'
WTF did I do?
-
I used a keyword as a function name.
Okay, so I'm back to "why the fuck does this work manually but not via Bamboo" land.
-
Why the fuck is
function test() {
OK but
function deploy() {
is not oka----
Is deploy a reserved word?
-
Doesn't look like it's reserved for bash? Maybe? Sorry, I can't help much beyond the google and sympathetic noises stage
-
Nope. So why will it take
function go() {
but not:
function go() {
This is clearly not a script problem.
-
Is deploy a reserved word?
No.
$ cat > test.sh function deploy() { echo TEST } deploy $ chmod +x test.sh $ ./test.sh TEST $
-
That's the same thing twice?
-
Bamboo:
- SSH's in as user foo
- Exports deploy.sh from svn
- Runs deploy.sh
- Barfs on line 1
I:
- SSH in as user foo
- Wrote a little test script
- Run the little test script
- Do not barf
I can also:
- SSH in as user foo
- SVN export the script
- run the script
- Barf
But the line I barf on in my real script and the line I barf on in my test script are Iden-----
LINE ENDINGS MAYBE?!
-
(flag authored by withdraw, will be automatically houred in 42 deletes unless posted)
-
IT WAS LINE ENDINGS.
FUCK EVERYTHING.
#endOfThread
-
What permissions are deploy.sh getting when bamboo remotes in? Is it getting 6 instead of 7?
-
My guess would have been bash versions. Or bash vs sh. Or bash vs bash in sh mode.
-
That was gonna be my guess, too.
#!/bin/bash
But it was line endings, apparently
-
This topic was automatically closed after 60 minutes. New replies are no longer allowed.