dabisu / sakura

GTK/VTE based terminal emulator
https://launchpad.net/sakura
GNU General Public License v2.0
176 stars 22 forks source link

-e option fails with file names containing spaces #42

Closed leo-arch closed 8 months ago

leo-arch commented 10 months ago

This command fails if FILE contains spaces:

sakura -e CMD FILE

It doesn't matter if the command is backgrounded or not, nor what opening application is used (here CMD), nor what file type FILE is, nor weather FILE is quoted/escaped or not. It just fails as soon as FILE contains spaces. A more concrete example:

sakura -e mpv "file name.mp4"

In order to make the above command work, two workarounds are possible:

a. Both quote and escape the file name: sakura -e mpv "file\ name.mp4" b. Escape the quotes: sakura -e mpv \"file name.mp4\"

Sakura version: 3.8.7

Maybe related to #35, or not. See this issue.

dabisu commented 8 months ago

I wouldn't call them workarounds, but the right way to reference a file with spaces when passing an argument to sakura ;)

It's not worth the time to make sakura parse the commands after the parameter "-e", specially if there's a way that allows you to execute the desired command.

leo-arch commented 8 months ago

Hi @dabisu, thanks for your answer.

FYI, I was just trying to use a user supplied terminal to run a command (in a script), something like this: "$term" -e "$app" "$file". This works with all terminal emulators I tried, but not with sakura: of course, it is easy to modify the script to either exclude sakura or modify the $file parameter at runtime, though none of these solutions are ideal. On the other side, sakura's way (both of them) will just not work on other terminals at all.

This said, this is not a sakura problem (per se), but only a compatibility issue. Not a big deal, but it's there.

dabisu commented 8 months ago

Hi @leo-arch!

I was looking into it to see if I could fix this without breaking anything else. I've submitted a patch so now it should work. Now it has a more consistent behaviour:

sakura -e mpv "file name.mp4" -> ok sakura -e mpv file\ name.mp4-> ok sakura -e mpv file name.mp4 -> not ok, there are 2 different parameters "file" and "name.mp4"

Let me know if it doesn't work for you. What I'm concerned about it's not that doesn't work, but that it will cause problems with another uses cases for other users. I'll leave as it is right now, but in case there are some regressions I'll have to try to fix it/restore the old behaviour again.

leo-arch commented 8 months ago

Works as expected @dabisu. Thanks!