I am currently writing a script where I have to call MATLAB from the Terminal and pass it a path argument that contains lousy characters.
As expected, I am running into trouble when the path contains spaces / parentheses. Here is a minimal example to illustrate the issue:
matlabcmd="/Applications/MATLAB_R2014b.app/bin/matlab -nodesktop -nosplash" run_dir="Users/Me/My Directory With Spaces (and parentheses)/" $matlabcmd -r "addpath('${run_dir}'),exit"
Some things that I have tried:
Different combinations of double-quotes and single-quotes in the commands above (this usually fails at calling MATLAB).
Using an escape character so that
run_dir="Users/Me/My Directory\ With\ Spaces\ \(and parentheses\)/"
(this manages to call MATLAB, but then MATLAB gets confused by the spaces... andaddpath
does not work).
Is there hope?