Emidee
Emidee

Reputation: 1275

"Command not found" when sourcing file with path variables

If I run this script:

#!/bin/bash

PROJECT_PATH="/Users/hudson/workspace/Foo"
XCODE_PROJECT_FOLDER="${PROJECT_PATH}/CODE/APP/FOO_IOS"

echo ${PROJECT_PATH}
echo ${XCODE_PROJECT_FOLDER}

It displays:

/Users/hudson/workspace/Foo

/Users/hudson/workspace/Foo/CODE/APP/FOO_IOS

If I put the variables in another file, include it in the main script file, and run it:

test.sh

#!/bin/bash

. "/Users/hudson/workspace/Foo/ota.sh"

echo ${PROJECT_PATH}
echo ${XCODE_PROJECT_FOLDER}

/Users/hudson/workspace/Foo/ota.sh

#!/bin/bash

PROJECT_PATH="/Users/hudson/workspace/Foo"
XCODE_PROJECT_FOLDER="${PROJECT_PATH}/CODE/APP/FOO_IOS"

I have this output:

: command not found /Users/hudson/workspace/Foo/ota.sh: line 2:

/Users/hudson/workspace/Foo

/CODE/APP/FOO_IOSkspace/Foo

Any idea of where the problem could come from?

Upvotes: 1

Views: 324

Answers (3)

ToddK
ToddK

Reputation: 765

As with the previous answer, probably wrong/mixed unix/windows line endings. If you are using notepad++,as Mike mentioned, in notepadd++, you can change the EOL character(s) by choosing the Edit menu, then EOL Conversion. After reading Mike's comment, that is what fixed this same exact problem that the op mentioned, that I was having too.

Upvotes: 0

l0b0
l0b0

Reputation: 58788

Try opening the file in vim, to see if there are any special characters there, like backspace.

Upvotes: 0

Karoly Horvath
Karoly Horvath

Reputation: 96258

Probably wrong/mixed unix/windows line endings, try to fix it with dos2unix.

Upvotes: 2

Related Questions