"Open With" appears to not quote paths?

I have a file called run.sh in the directory /home/a/Documents/PHP stuff/1. Test.

If I open that directory in Dolphin and right-click the file, pick “Open With” and then click “Terminal Emulator” (or any other terminal option/program), it opens a terminal window displaying a pop-up error box saying:

Failed to execute child
Failed to execute child process "/home/a/Documents/PHP":
Failed to execve: No such file or directory

It nonsensically stops after the first space in the path, just as if it’s not being quoted! However, I refuse to believe that this could be a fundamental bug in KDE/Plasma/Dolphin, being such a mature project, so I must assume that something else is wrong.

Please note that it works whenever the path doesn’t contain any spaces, but it’s definitely not an option to rename my entire directory tree!

I remember having the same issue in XFCE, but don’t remember how I solved it there. I think the apparent error may be misleading.

It’s also not an option to modify the contents of the run.sh file. I know that I could make it manually call a specific terminal, but this is equally impractical and “unclean” for complicated-to-explain reasons.

What do you expect “Open With” with a script and a terminal emulator to do ?

Run it, or open it in a terminal editor (i.e vim/emacs) ?

Because we have a “Run in konsole” for executable files in the context menu, or you would double click the file.
And to open in a terminal editor, you would need to select the editor in Open With menu, not a terminal program.

Does it happen with konsole as well (I don’t reproduce this, but I am on Plasma6), it opens konsole in ~/Téléchargements/Nouveau dossier/Test 1. in my case, which would be the expected behavior.

The fact that you get an error seems to indicate to me a problem in the gnome-terminal (aka Terminal Emulator), not interpreting quoted strings correctly.

Also in next dolphin release (23.04), you will be able to middle click on script to open them in the default configured editor associated with that mimetype.