I need to pass filename as input to a powershell command which includes spaces. Hence I am hoping to include double quotes.
However, Matlab "eats" all double quotes in the input of system()
when passing arguments to powershell.
For example, note how the examples below all the the same output.
>> system('powershell.exe echo a c','-echo')
a
c
ans =
0
>> system('powershell.exe echo "a c"','-echo')
a
c
ans =
0
>> system('powershell.exe echo ""a c""','-echo')
a
c
ans =
0
>> system(['powershell.exe echo ',char(34),'a c',char(34)],'-echo')
a
c
ans =
0
The actual output for echo "a c"
in powershell is a c
in a single line. The change of line only occurs without double quotes.
Just for experiment, I also tried ""a c""
and the expected input is the same as change line, a, change line, c. With the return, it seems that any and all double quotes are "eaten" alive by Matlab.
How do I bring the double quotes back when using system()
?