Reputation: 1043
I was trying to automate a small build process using shell scripting. Build process is basically:
cd /location/to/build.xml
I created a build.sh file which I intend to use as ./build.sh release
to build release version, and my shell script file is:
ANT_BUILD_PATH="/Path/To/ant"
cd "/Location/To/Build.xml"
"$ANT_BUILD_PATH $1"
I get ant not a file or command
when I execute this shell file as ./build.sh release
even though the ant file is there.
Also, when I use "$ANT_BUILD_PATH" "$1"
. Script runs just fine.
What is the difference between "$ANT_BUILD_PATH $1"
and "$ANT_BUILD_PATH" "$1"
Upvotes: 1
Views: 160
Reputation: 195229
The different is, when you do "$ANT... $1"
, shell execute a command called /path/to/ant release
, note, it is one command with space as part of command. So command not found.
But if you "$ANT..." "$1"
it will execute command /paht/to/ant
, and take release
as argument/option.
Test with this, you will see:
kent$ "ls -l"
zsh: command not found: ls -l #it thinks a command is "ls(space)-l"
kent$ "ls" "-l"
total xx
<file lists>
Upvotes: 3
Reputation: 17721
"$ANT_BUILD_PATH $1"
passes one string to the shell, composed by the concatenation of the ant build path and the parameter. This is not what you want.
"$ANT_BUILD_PATH" "$1"
passes two strings to the shell: the ant build path as the first string, and the parameter as the second string. This is what you want :-).
Upvotes: 1