changeset 30778:e36380193f2b stable

pkg: Allow spaces in paths to Octave binaries (bug #62090). * scripts/pkg/private/configure_make.m: Escape (not already escaped) spaces in paths to Octave binaries (mkoctfile, octave_config, and octave).
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 25 Feb 2022 15:37:46 +0100
parents 2aff9dda08f1
children 73404743f3de d041ca628d99
files scripts/pkg/private/configure_make.m
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/pkg/private/configure_make.m	Mon Feb 21 13:01:26 2022 -0500
+++ b/scripts/pkg/private/configure_make.m	Fri Feb 25 15:37:46 2022 +0100
@@ -52,6 +52,19 @@
       __gripe_missing_component__ ("pkg", "octave");
     endif
 
+    if (ispc () && ! isunix ())
+      # replace all backslashes with forward slashes
+      mkoctfile_program = strrep (mkoctfile_program, '\', '/');
+      octave_config_program = strrep (octave_config_program, '\', '/');
+      octave_binary = strrep (octave_binary, '\', '/');
+    endif
+
+    # escape spaces in file paths unless they are already escaped
+    mkoctfile_program = regexprep (mkoctfile_program, '([^\\]) ', '$1\\ ');
+    octave_config_program = regexprep (octave_config_program, ...
+                                       '([^\\]) ', '$1\\ ');
+    octave_binary = regexprep (octave_binary, '([^\\]) ', '$1\\ ');
+
     if (verbose)
       mkoctfile_program = [mkoctfile_program " --verbose"];
     endif
@@ -151,7 +164,6 @@
 function [status, output] = shell (cmd, verbose)
   persistent have_sh;
 
-  cmd = strrep (cmd, '\', '/');
   if (ispc () && ! isunix ())
     if (isempty (have_sh))
       if (system ('sh.exe -c "exit"'))