Skip to content

Commit

Permalink
Fixes KeyFilePath parameter for Linux systems (PowerShell#4529)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHigin authored and adityapatwardhan committed Aug 15, 2017
1 parent b953ab1 commit 6b8d86f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,35 @@ private static string[] ParseArgv(ProcessStartInfo psi)
{
var argvList = new List<string>();
argvList.Add(psi.FileName);
argvList.AddRange(psi.Arguments.Split(' '));

var argsToParse = psi.Arguments.Trim();
var argsLength = argsToParse.Length;
for (int i=0; i<argsLength; )
{
var iStart = i;

switch (argsToParse[i])
{
case '"':
// Special case for arguments within quotes
// Just return argument value within the quotes
while ((++i < argsLength) && argsToParse[i] != '"') { };
if (iStart < argsLength - 1)
{
iStart++;
}
break;

default:
// Common case for parsing arguments with space character delimiter
while ((++i < argsLength) && argsToParse[i] != ' ') { };
break;
}

argvList.Add(argsToParse.Substring(iStart, (i-iStart)));
while ((++i < argsLength) && argsToParse[i] == ' ') { };
}

return argvList.ToArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,12 @@ internal override void CreateAsync()
StartReaderThread(_stdOutReader);
}

internal override void CloseAsync()
{
base.CloseAsync();
CloseConnection();
}

#endregion

#region Private Methods
Expand Down

0 comments on commit 6b8d86f

Please sign in to comment.