Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs (C#)

Code before:

        /// <summary>
        /// StartSSHProcess.
        /// </summary>
        /// <returns></returns>
        internal int StartSSHProcess(
            out StreamWriter stdInWriterVar,
            out StreamReader stdOutReaderVar,
            out StreamReader stdErrReaderVar)
        {
            string filePath = string.Empty;
#if UNIX
            const string sshCommand = "ssh";
#else
            const string sshCommand = "ssh.exe";
#endif
            var context = Runspaces.LocalPipeline.GetExecutionContextFromTLS();
            if (context != null)
            {
                var cmdInfo = CommandDiscovery.LookupCommandInfo(
                    sshCommand,
                    CommandTypes.Application,
                    SearchResolutionOptions.None,
                    CommandOrigin.Internal,
                    context) as ApplicationInfo;
                if (cmdInfo != null)
                {
                    filePath = cmdInfo.Path;
                }
            }
            else
            {
                // A Runspace may not be present in the TLS in SDK hosted apps
                // or if running in another thread without a Runspace. While
                // ProcessStartInfo can lookup the full path in PATH, we set
                // the cwd to the parent directory of the found executable so
                // we do a manual lookup here.
                string[] entries = Environment.GetEnvironmentVariable("PATH")?.Split(
                    Path.PathSeparator,
                    StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
                foreach (var path in entries)
                {
                    if (!Path.IsPathFullyQualified(path))
                    {
                        continue;
                    }

                    var sshCommandPath = Path.Combine(path, sshCommand);
                    if (File.Exists(sshCommandPath))
                    {
                        filePath = sshCommandPath;

Review comment (suggestion):
Style nitpick.
```suggestion
                    context) as ApplicationInfo;

                if (cmdInfo != null)
```

Code after:

        /// <summary>
        /// StartSSHProcess.
        /// </summary>
        /// <returns></returns>
        internal int StartSSHProcess(
            out StreamWriter stdInWriterVar,
            out StreamReader stdOutReaderVar,
            out StreamReader stdErrReaderVar)
        {
            string filePath = string.Empty;
#if UNIX
            const string sshCommand = "ssh";
#else
            const string sshCommand = "ssh.exe";
#endif
            var context = Runspaces.LocalPipeline.GetExecutionContextFromTLS();
            if (context != null)
            {
                var cmdInfo = CommandDiscovery.LookupCommandInfo(
                    sshCommand,
                    CommandTypes.Application,
                    SearchResolutionOptions.None,
                    CommandOrigin.Internal,
                    context) as ApplicationInfo;

                if (cmdInfo != null)
                {
                    filePath = cmdInfo.Path;
                }
            }
            else
            {
                // A Runspace may not be present in the TLS in SDK hosted apps
                // or if running in another thread without a Runspace. While
                // 'ProcessStartInfo' can lookup the full path in PATH, it searches
                // the process' working directory first. 'LookupCommandInfo' does
                // not search the process' working directory and we want to keep that
                // behavior. We also get the parent dir of the full path to set as the
                // new WorkingDirectory. So, we do a manual lookup here only in PATH.
                string[] entries = Environment.GetEnvironmentVariable("PATH")?.Split(
                    Path.PathSeparator,
                    StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
                foreach (var path in entries)
                {
                    if (!Path.IsPathFullyQualified(path))
                    {
                        continue;
                    }

                    var sshCommandPath = Path.Combine(path, sshCommand);