I'm using MSYS to get some semblance of a sane scriptable shell on Windows :).
Now I'm writing a console application, written in C#, that accepts a number of arguments and presents those as options to the user in a dialog box. The actual options correspond to file names, that I'm retrieving with ls.
However, trouble appears when I have file names with spaces in them. Let's say I have files named:
file name
with spaces
In a directory called foo, my C# executable is called bar, and inside I inspect the contents of the "argv" array (i.e., the command-line arguments passed to my application, as interpreted by .NET).
The following strangeness happens when I call it:
./bar.exe "file name" "with spaces" -->
file name
with spaces
./bar.exe $(ls foo) -->
file
name
with
spaces
./bar.exe $(ls -Q foo) -->
"file
name"
"with
spaces"
Does anyone know what is happening here? Apparently, .NET is not parsing the arguments as passed by either bash or ls correctly.
But even when I add quotes, the quotes are included in the arguments instead of combining two arguments into one.
Is there even a way for me to get at the unprocessed command-line, so I can see if there's funkiness happening with control characters or something?
Any insight would be greatly appreciated!