wine 'start' strips out quotes?

Questions about Wine on Linux
Post Reply
Posts: 3
Joined: Thu Nov 08, 2018 11:15 am

wine 'start' strips out quotes?

Post by Remdul » Wed Oct 13, 2021 9:02 am

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:

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!

Level 10
Level 10
Posts: 1691
Joined: Thu Aug 14, 2014 10:10 am

Re: wine 'start' strips out quotes?

Post by jkfloris » Sat Oct 16, 2021 11:55 am

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

(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"

Level 4
Level 4
Posts: 136
Joined: Thu May 22, 2008 3:18 am
Location: Manila, Philippines

Re: wine 'start' strips out quotes?

Post by Bamm » 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.

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.

Post Reply