Here is a part from my deployment automation script:
$SVNEXE = "$env:ProgramFiles\TortoiseSVN\bin\svn.exe"
foreach ($element in $commandstoken) {
#$exportfile = [System.Web.HttpUtility]::UrlPathDecode($StreamServe5RepoURI + $commandstoken[$a])
$exportfile = ($StreamServe5RepoURI + $commandstoken[$a])
$SVNRevision = $commandstoken[$a+1]
[string]$SVNCommand = "export -r $SVNRevision --force"
Write-Host -ForegroundColor Red $SVNCommand
Write-Host -ForegroundColor Red $SVNCommand $exportfile
&"$SVNEXE" $SVNCommand $exportfile "C:\Temp\__foo\export"
$a = $a+2
}
I want to pass the svn.exe the $SVNCommand
variable but the svn.exe throws an error: svn.exe : Unknown subcommand: 'export -r 2384 --force'
As far as I can see the variable expansion is working so I can not understand why the svn.exe
throws this error.
The error
Unknown subcommand: 'export -r 2384 --force'
suggests that call operator treats'export -r 2384 --force''export -r 2384 --force'
this like a single argument (from technet on the & call operator):In your case, you could do something like like suggested on that page:
And invoke with all arguments like this:
The only way I got it to work is to hold every parameter in a separate variable:
This seems actually bug Executing commands which require quotes and variables is practically impossible