wine 'start' strips out quotes?

Questions about Wine on Linux
Locked
Remdul
Level 1
Level 1
Posts: 9
Joined: Thu Nov 08, 2018 11:15 am

wine 'start' strips out quotes?

Post by Remdul »

I'm trying to do the following to start gedit (or any other Linux native application) from my windows application running on Wine:

Code: Select all

cmd /c start /unix /usr/bin/gedit "/home/bob/.wine32/drive_c/Program Files/some path with spaces/file name with spaces .txt"
In this case, gedit should open the file "/home/bob/.wine32/drive_c/Program Files/some path with spaces/file name with spaces .txt".
However, whatever I try, the quotes around the path are *always* stripped away.
I know my quotes path string is proper, because:

Code: Select all

cmd /k set myenvvar="/my path with spaces/"
look alright when I echo %myenvvar%. I can add hundreds of quotes, single quotes, double quotes, backslashes, just about any escape character, spaces, any character I throw at it, it ends up fine in the Windows environment variable. But as soon as I pass the contents to 'start', it comes out unquoted in Linux, hence gedit giving me half a dozen error message boxes reporting it can't find:
"/my"
"path"
"with"
"spaces/"
etc.

So something is removing the quotes, and I suspect Wine's 'start' process. It doesn't do anything with escape characters, they pass through fine (backslashes end up in the erroneous paths reported by nemo). It's just double or single quotes that are stripped, and the remaining path string is split into arguments by the Linux application.

I've tried messing with cmd /S flag, but it doesn't help, because cmd already handles things properly.

I would love to have some ideas on how to solve this problem. Currently, the only way I can think of is to write a Linux native application, reading the path from a temporary file and running the requested Linux native command. But this would be basically re-implementing 'start', while using 'start' to run it!
jkfloris
Level 12
Level 12
Posts: 3136
Joined: Thu Aug 14, 2014 10:10 am

Re: wine 'start' strips out quotes?

Post by jkfloris »

The following seems to work:

From the WineHQ Wiki:
First, run regedit and add a dot character to the end of the list of extensions in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATHEXT.
So it looks like this:

Code: Select all

.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.
(Note that this change will have to be made every time you upgrade Wine, as it will be reverted whenever the wineprefix is updated.)

Now you can start gedit with:

Code: Select all

wine cmd /c /usr/bin/gedit "/home/bob/.wine32/drive_c/Program Files/some path with spaces/file name with spaces .txt"
Bamm
Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am

Re: wine 'start' strips out quotes?

Post by Bamm »

start removes quotes because windows start.exe in windows behaves the same way, and windows programs expect that behavior.

if you replace gedit by notepad.exe you will see that notepad has no problems finding the file even without the quotes, but gedit thinks they are several separate arguments.

conversely, if you add quotes and pass them to notepad.exe, it will think the quotes are part of the filename and will not find it.

if start behaved the unix way, then many windows programs will not work.

i encountered that problem before and i solved it by creating an in-between shell script which passes "$*" (with quotes) to gedit. This combines the arguments into a single argument.
Remdul
Level 1
Level 1
Posts: 9
Joined: Thu Nov 08, 2018 11:15 am

Re: wine 'start' strips out quotes?

Post by Remdul »

Interesting. This make it absolutely, definitively, forever impossible to pass any Linux paths containing spaces to a Linux-native application that itself resides in a directory containing spaces, because it cannot be launched. And this homebrew application was undoing the unquoting done by 'start' in the first place, in order to start the real Linux native application I was targeting. Gedit I used in my post was just an example repro case.

I guess I'll simply ask my users to manually place a symlink to said Linux binary in the Wine prefix C:\ directory as workaround. My application cannot create that symlink for the same reason as above.

Or maybe I can launch the Linux-native application in a VM within the Wine environment? Sometimes recursive problems need recursive solutions!
Remdul
Level 1
Level 1
Posts: 9
Joined: Thu Nov 08, 2018 11:15 am

Re: wine 'start' strips out quotes?

Post by Remdul »

I just realized start doesn't launch anything at all anymore, with or without paths. I only get the following errors:

"File not found"
[ OK ]

or

"Invalid name"
[ OK ]

Both repeated 10 times.

Anyone know what that means?
Remdul
Level 1
Level 1
Posts: 9
Joined: Thu Nov 08, 2018 11:15 am

Re: wine 'start' strips out quotes?

Post by Remdul »

Bamm wrote: Mon Oct 25, 2021 1:28 pm start removes quotes because windows start.exe in windows behaves the same way, and windows programs expect that behavior.
Is that actually true? Is it not a regression? Because in previous versions of Wine, the same commands worked fine.
Locked