Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should now be able to handle spaces in filenames #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/com/github/maven_nar/NarGnuConfigureMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti
getLog().info("Running GNU " + BUILDCONF);
String gnuBuildconfArgsArray[] = null;
if (this.gnuBuildconfArgs != null) {
gnuBuildconfArgsArray = this.gnuBuildconfArgs.split("\\s");
gnuBuildconfArgsArray = this.gnuBuildconfArgs.split("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'");
}
runAutogen(buildconf, targetDir, gnuBuildconfArgsArray);
}
Expand All @@ -154,7 +154,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti

// create the array to hold constant and additional args
if (this.gnuConfigureArgs != null) {
final String[] a = this.gnuConfigureArgs.split(" ");
final String[] a = this.gnuConfigureArgs.split("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'");
args = new String[a.length + 2];

System.arraycopy(a, 0, args, 2, a.length);
Expand All @@ -164,7 +164,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti

// first 2 args are constant
args[0] = configure.getAbsolutePath();
args[1] = "--prefix=" + getGnuAOLTargetDirectory().getAbsolutePath();
args[1] = "--prefix=\"" + getGnuAOLTargetDirectory().getAbsolutePath() + "\"";

final File buildDir = getGnuAOLSourceDirectory();
FileUtils.mkdir(buildDir.getPath());
Expand Down Expand Up @@ -196,7 +196,7 @@ private void runAutogen(final File autogen, final File targetDir, final String a
} else {
arguments = new String[1];
}
arguments[0] = "./" + autogen.getName();
arguments[0] = "\"./" + autogen.getName() + "\"";

getLog().info("args: " + arraysToString(arguments));

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/maven_nar/NarUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static void makeExecutable(final File file, final Log log) throws MojoExe
if (file.isFile() && file.canRead() && file.canWrite() && !file.isHidden()) {
// chmod +x file
final int result = runCommand("chmod", new String[] {
"+x", file.getPath()
"+x", file.getPath().replaceAll(" ", "\\ ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because chmod is called directly rather than using shell sh additional escaping or quoting for spaces shouldn't be required.
Was this required or "added for safety" ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to remember this being required.

}, null, null, log);
if (result != 0) {
throw new MojoExecutionException("Failed to execute 'chmod +x " + file.getPath() + "'" + " return code: \'"
Expand Down