Bug 573677: Use array based exec commands to avoid problems with spaces

While most of these commands don't actually have spaces in them, or
their arguments, avoid the deprecated methods.

Change-Id: If7b4324695699d5a6d9a2f8a979657977486d8a4
diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java
index 864da2f..485493b 100644
--- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java
+++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java
@@ -50,9 +50,10 @@
 	public static void beforeClassMethod() {
 		// Verify that the necessary binaries are available, and if they are not,
 		// the tests will be ignored.
-		String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" };
+		String[][] testBinaryCommands = { { "libtool", "--version" }, { "autoconf", "--version" },
+				{ "automake", "--version" } };
 		try {
-			for (String cmd : testBinaryCommands) {
+			for (String[] cmd : testBinaryCommands) {
 				Process process = ProcessFactory.getFactory().exec(cmd);
 				process.destroy();
 			}
diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java
index f498ad8..d1c59a7 100644
--- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java
+++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java
@@ -48,9 +48,10 @@
 	public static void beforeClassMethod() {
 		// Verify that the necessary binaries are available, and if they are not,
 		// the tests will be ignored.
-		String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" };
+		String[][] testBinaryCommands = { { "libtool", "--version" }, { "autoconf", "--version" },
+				{ "automake", "--version" } };
 		try {
-			for (String cmd : testBinaryCommands) {
+			for (String[] cmd : testBinaryCommands) {
 				Process process = ProcessFactory.getFactory().exec(cmd);
 				process.destroy();
 			}
diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
index f18fc6d..cec1580 100644
--- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
+++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java
@@ -109,7 +109,7 @@
 		Path x = new Path(input);
 		try {
 			if (!x.isAbsolute() && x.segmentCount() == 1) {
-				String command = "which " + input; //$NON-NLS-1$
+				String[] command = new String[] { "which", input }; //$NON-NLS-1$
 				Process p = null;
 				InputStream in = null;
 				try {
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
index b753b13..3c14f00 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java
@@ -680,7 +680,7 @@
 				String server = (String) launchAttributes.get(ATTR_DEBUG_SERVER_NAME);
 				String port = (String) launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_PORT);
 				String program = (String) launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME);
-				String commandLine = server + " :" + port + " " + program;
+				String[] commandLine = { server, ":" + port, program };
 				try {
 					if (GdbDebugOptions.DEBUG)
 						GdbDebugOptions.trace("Starting gdbserver with command: " + commandLine + "\n");
@@ -787,7 +787,7 @@
 	}
 
 	protected static String doReadGdbVersion(String gdb) throws IOException {
-		Process process = ProcessFactory.getFactory().exec(gdb + " --version");
+		Process process = ProcessFactory.getFactory().exec(new String[] { gdb, "--version" });
 		try {
 			String streamOutput;
 			try (BufferedReader buffer = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
diff --git a/launch/org.eclipse.cdt.flatpak.launcher-feature/feature.properties b/launch/org.eclipse.cdt.flatpak.launcher-feature/feature.properties
index 628aaaa..d260768 100644
--- a/launch/org.eclipse.cdt.flatpak.launcher-feature/feature.properties
+++ b/launch/org.eclipse.cdt.flatpak.launcher-feature/feature.properties
@@ -1,5 +1,5 @@
 #################################################################################
-#  Copyright (c) 2020 Red Hat, Inc.
+#  Copyright (c) 2020, 2021 Red Hat, Inc.
 #
 #  This program and the accompanying materials
 #  are made available under the terms of the Eclipse Public License 2.0
@@ -15,7 +15,7 @@
 description=Plugins for launching C/C++ applications in Eclipse Flatpak.
 provider=Eclipse CDT
 copyright=\
-Copyright (c) 2020 Red Hat, Inc. and others.\n\
+Copyright (c) 2020, 2021 Red Hat, Inc. and others.\n\
 This program and the accompanying materials\n\
 are made available under the terms of the Eclipse Public License 2.0\n\
 which accompanies this distribution, and is available at\n\
diff --git a/launch/org.eclipse.cdt.flatpak.launcher/META-INF/MANIFEST.MF b/launch/org.eclipse.cdt.flatpak.launcher/META-INF/MANIFEST.MF
index c8b4246..42a2790 100644
--- a/launch/org.eclipse.cdt.flatpak.launcher/META-INF/MANIFEST.MF
+++ b/launch/org.eclipse.cdt.flatpak.launcher/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.cdt.flatpak.launcher;singleton:=true
-Bundle-Version: 1.0.100.qualifier
+Bundle-Version: 1.0.200.qualifier
 Bundle-Activator: org.eclipse.cdt.flatpak.launcher.FlatpakLaunchPlugin
 Bundle-Vendor: %Plugin.vendor
 Bundle-Localization: plugin
diff --git a/launch/org.eclipse.cdt.flatpak.launcher/src/org/eclipse/cdt/flatpak/launcher/FlatpakCommandLauncherFactory.java b/launch/org.eclipse.cdt.flatpak.launcher/src/org/eclipse/cdt/flatpak/launcher/FlatpakCommandLauncherFactory.java
index 697046a..1bfa1ed 100644
--- a/launch/org.eclipse.cdt.flatpak.launcher/src/org/eclipse/cdt/flatpak/launcher/FlatpakCommandLauncherFactory.java
+++ b/launch/org.eclipse.cdt.flatpak.launcher/src/org/eclipse/cdt/flatpak/launcher/FlatpakCommandLauncherFactory.java
@@ -191,11 +191,11 @@
 					}
 					try {
 						Process p1 = ProcessFactory.getFactory()
-								.exec("mkdir -p " + pluginPath.append(path).toOSString()); //$NON-NLS-1$
+								.exec(new String[] { "mkdir", "-p", pluginPath.append(path).toOSString() }); //$NON-NLS-1$ //$NON-NLS-2$
 						int rc1 = waitFor(p1);
 						if (rc1 == 0) {
-							Process p2 = ProcessFactory.getFactory().exec("cp -ru " + path //$NON-NLS-1$
-									+ " " + pluginPath.append(path).removeLastSegments(1).toOSString()); //$NON-NLS-1$
+							Process p2 = ProcessFactory.getFactory().exec(new String[] { "cp", "-ru", "path", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+									pluginPath.append(path).removeLastSegments(1).toOSString() });
 							int rc2 = waitFor(p2);
 							if (rc2 == 0) {
 								copiedDirs.add(path);
@@ -270,11 +270,11 @@
 					if (!copiedDirs.contains(path)) {
 						try {
 							Process p1 = ProcessFactory.getFactory()
-									.exec("mkdir -p " + copiedPath.append(path).toOSString()); //$NON-NLS-1$
+									.exec(new String[] { "mkdir", "-p", copiedPath.append(path).toOSString() }); //$NON-NLS-1$ //$NON-NLS-2$
 							int rc1 = waitFor(p1);
 							if (rc1 == 0) {
-								Process p2 = ProcessFactory.getFactory().exec("cp -ru " + path //$NON-NLS-1$
-										+ " " + copiedPath.append(path).removeLastSegments(1).toOSString()); //$NON-NLS-1$
+								Process p2 = ProcessFactory.getFactory().exec(new String[] { "cp", "-ru", path, //$NON-NLS-1$ //$NON-NLS-2$
+										copiedPath.append(path).removeLastSegments(1).toOSString() });
 								int rc2 = waitFor(p2);
 								if (rc2 == 0) {
 									copiedDirs.add(path);
@@ -321,11 +321,11 @@
 					if (removedDirs.contains(path)) {
 						try {
 							Process p1 = ProcessFactory.getFactory()
-									.exec("mkdir -p " + hostDir.append(path).toOSString()); //$NON-NLS-1$
+									.exec(new String[] { "mkdir", "-p", hostDir.append(path).toOSString() }); //$NON-NLS-1$ //$NON-NLS-2$
 							int rc1 = waitFor(p1);
 							if (rc1 == 0) {
-								Process p2 = ProcessFactory.getFactory().exec("cp -ru " + path //$NON-NLS-1$
-										+ " " + hostDir.append(path).removeLastSegments(1).toOSString()); //$NON-NLS-1$
+								Process p2 = ProcessFactory.getFactory().exec(new String[] { "cp", "-ru", path, //$NON-NLS-1$ //$NON-NLS-2$
+										hostDir.append(path).removeLastSegments(1).toOSString() });
 								int rc2 = waitFor(p2);
 								if (rc2 == 0) {
 									copiedDirs.add(path);