# HG changeset patch # User Alexander Simon # Date 1445267473 -10800 # Mon Oct 19 18:11:13 2015 +0300 # Node ID 9398828b699353267a769e92a97dbada5ca4b47f # Parent d9aa4b6adda86e37c2191dfad9b163b9c46c5f44 fixed Bug #255936 "Unable to find any valid shell." window instead of External Terminal diff --git a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ExecuteCommand.java b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ExecuteCommand.java --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ExecuteCommand.java +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/projectimport/ExecuteCommand.java @@ -66,6 +66,7 @@ import org.netbeans.modules.cnd.makeproject.api.wizards.PreBuildSupport; import org.netbeans.modules.cnd.spi.toolchain.CompilerLineConvertor; import org.netbeans.modules.cnd.spi.toolchain.ToolchainProject; +import org.netbeans.modules.cnd.utils.CndPathUtilities; import org.netbeans.modules.cnd.utils.CndUtils; import org.netbeans.modules.nativeexecution.api.*; import org.netbeans.modules.nativeexecution.api.execution.NativeExecutionDescriptor; @@ -114,7 +115,7 @@ } private NativeExecutionService prepare(ExecutionListener listener, Writer outputListener, List additionalEnvironment) { - final HostInfo hostInfo; + HostInfo hostInfo; try { hostInfo = HostInfoUtils.getHostInfo(execEnv); } catch (IOException ex) { @@ -126,6 +127,30 @@ } // Executable String executable = hostInfo.getShell(); + if (executable == null) { + if (hostInfo.getOS().getFamily() == HostInfo.OSFamily.WINDOWS) { + CompilerSet compilerSet = getCompilerSet(); + if (compilerSet != null && compilerSet.getCompilerFlavor().isMinGWCompiler()) { + String commandFolder = compilerSet.getCommandFolder(); + if (commandFolder != null) { + // reinit shell + WindowsSupport.getInstance().init(commandFolder); + try { + HostInfoUtils.updateHostInfo(execEnv); + hostInfo = HostInfoUtils.getHostInfo(execEnv); + executable = hostInfo.getShell(); + } catch (IOException ex) { + } catch (InterruptedException ex) { + } catch (CancellationException ex) { + } + } + } + } + if (executable == null) { + ImportProject.logger.log(Level.INFO, "Shell command is null"); //NOI18N + return null; + } + } expandMacros(hostInfo, BuildSupport.MAKE_MACRO, PredefinedToolKind.MakeTool, "make"); //NOI18N expandMacros(hostInfo, PreBuildSupport.C_COMPILER_MACRO, PredefinedToolKind.CCompiler, "gcc"); //NOI18N expandMacros(hostInfo, PreBuildSupport.CPP_COMPILER_MACRO, PredefinedToolKind.CCCompiler, "g++"); //NOI18N diff --git a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/MakeActionProvider.java @@ -1804,12 +1804,36 @@ activeShell = WindowsSupport.getInstance().getActiveShell(); shellValidationStatus = ShellValidationSupport.getValidationStatus(activeShell); isOK = shellValidationStatus.isValid() && !shellValidationStatus.hasWarnings(); + if (isOK) { + try { + HostInfoUtils.updateHostInfo(execEnv); + } catch (IOException ex) { + } catch (InterruptedException ex) { + } + } } } if (!isOK) { lastValidation = ShellValidationSupport.confirm(shellValidationStatus); } + } else if (cs.getCompilerFlavor().isMinGWCompiler()) { + Shell activeShell = WindowsSupport.getInstance().getActiveShell(); + if (activeShell == null) { + String binDir = cs.getCommandFolder(); + // Perhaps one that is provided is better? + WindowsSupport.getInstance().init(binDir); + activeShell = WindowsSupport.getInstance().getActiveShell(); + if (activeShell == null) { + lastValidation = ShellValidationSupport.confirm(null); + } else { + try { + HostInfoUtils.updateHostInfo(execEnv); + } catch (IOException ex) { + } catch (InterruptedException ex) { + } + } + } } } diff --git a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/WindowsRegistryIterator.java b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/WindowsRegistryIterator.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/WindowsRegistryIterator.java +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/WindowsRegistryIterator.java @@ -206,7 +206,12 @@ suffix.append(" /s "); // NOI18N } if (valueName != null) { - suffix.append(" /v ").append(valueName); // NOI18N + suffix.append(" /v "); // NOI18N + if (valueName.indexOf(' ')>0) { // NOI18N + suffix.append('"').append(valueName).append('"'); // NOI18N + } else { + suffix.append(valueName); + } } if (fullKey.indexOf(' ')>0) { fullKey = "\""+fullKey+"\""; // NOI18N