mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
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
This commit is contained in:
parent
1ac907184b
commit
d907da99a4
7 changed files with 21 additions and 19 deletions
|
@ -50,9 +50,10 @@ public abstract class BaseParserTest {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -48,9 +48,10 @@ public class TestTokenizer {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
|||
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 {
|
||||
|
|
|
@ -680,7 +680,7 @@ public class BaseTestCase {
|
|||
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 @@ public class BaseTestCase {
|
|||
}
|
||||
|
||||
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()))) {
|
||||
|
|
|
@ -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 @@ featureName=C/C++ Flatpak Launch Support
|
|||
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\
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
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
|
||||
|
|
|
@ -191,11 +191,11 @@ public class FlatpakCommandLauncherFactory
|
|||
}
|
||||
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 @@ public class FlatpakCommandLauncherFactory
|
|||
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 @@ public class FlatpakCommandLauncherFactory
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue