Reputation:
I can successfully run the following command in the shell.
export ANT_HOME=/users/user1/workspace/apache-ant-1.7.0
But when I am adding the same line in a shell script, I am getting the following error.
`/users/user1/workspace/apache-ant-1.7.0': not a valid identifier
The shell interpreter is taking -1.7.0 in the path as a arithmetic operation.
How can I fix this ?
EDIT : the shell script which I am trying to run is here.
#!/bin/sh
settingsForANT()
{
export ANT_HOME=/users/user1/workspace/apache-ant-1.7.0
export PATH=${PATH}:${ANT_HOME}/bin
echo $ANT_HOME
echo $PATH
}
settingsForANT
Upvotes: 0
Views: 79
Reputation: 882136
Most likely you either have a $
before the ANT_HOME
or a space after the =
, probably the latter.
It's complaining about your path being an invalid identifier, meaning it's on the left hand of an assignment, not the right.
If that turns out to be not the case, check the shell you're running the script as. Some do not allow combined set/export
and you may need:
ANT_HOME=whatever; export ANT_HOME
Upvotes: 3