0

How can I include spaces as part of a variable used in an svn command for RHEL bash scripting? Or if there's something else wrong with the following, please advise.

The SVN URL variable has no spaces, and this section is working:

svn checkout $svnUrl $checkoutDir --username $username --password $password --non-interactive --depth immediates --no-auth-cache

But the SVN update command that works when hard coded is not working as a variable:

updateSubProject="&& svn update --set-depth infinity --no-auth-cache --username $username --password $password --non-interactive"
cd project-dir $updateSubProject
cd ../another-project $updateSubProject
dev_feed
  • 103

2 Answers2

6

Better would be to make a function to do it like

updateSubProject() {
    pushd "$1"
    svn checkout "$svnUrl" "$checkoutDir" --username "$username" --password "$password" --non-interactive --depth immediates --no-auth-cache
    popd
}

updateSubProject project-dir
updateSubProject path/to/another-project

this way you aren't trying to store code in a variable, and you'll avoid a lot of the word splitting issues.

Eric Renouf
  • 18,431
1

You can try to execute the command that is stored in variable with
eval "$updateSubProject"
so remove the double & from varable and go for:
cd project-dir && eval "$updateSubProject"

igiannak
  • 750