问题
I'm trying to use powershell to do a "get" from srcSafe using a label that contains spaces.
I've read what seems like numerous posts about how to pass params w/spaces to exe's but nothing I've tried works. My problem appears to be supplying the label correctly.
Following is the cmd line version ( which works ).
ss get $/sandbox/TestSSCmdLine/* -R -I-N -VL"label space"
My simplest powershell version is:
ss get '$/sandbox/TestSSCmdLine/*' -R -I-N '-VL\"label space\"'
When I run the powershell cmd I get no files and $lastexitcode is "100".
Echo args shows what I think should be correct.
Arg 0 is <get>
Arg 1 is <$/sandbox/TestSSCmdLine/*>
Arg 2 is <-R>
Arg 3 is <-I-N>
Arg 4 is <-VL"label space">
Powershell ISE shows the same.
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Raw argument string: get $/sandbox/TestSSCmdLine/* -R -I-N "-VL\"label space\""
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Argument 0: get
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Argument 1: $/sandbox/TestSSCmdLine/*
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Argument 2: -R
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Argument 3: -I-N
DEBUG: NativeCommandParameterBinder Information: 0 : WriteLine Argument 4: -VL"label space"
Just to confuse things start-process seems to work:
$cmd = "ss.exe"
$args = "get", '$/sandbox/TestSSCmdLine/*', "-R", "-I-N", '-VL"label space"'
$proc = start-process $cmd $args -Wait -NoNewWindow -PassThru -WorkingDir $pwd
$proc.ExitCode
An additional confusing item is the fact the echo args now shows the version parameter as: Arg 4 is <-VLlabel space> -> note no spaces, also does not work from cmd line.
Thanx for any help!
John A.
回答1:
In cmd
, the quotes would have been used to ensure label space
was passed as a part of the -VL
argument. Since the Start-Process
version works with a result argument of -VLlabel space
, I would try calling ss
with '-VLlabel space'
, without any embedded quotes (third option listed at the top of this answer).
来源:https://stackoverflow.com/questions/11462737/problems-using-powershell-to-perform-a-source-safe-get-by-label