Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Starting programs with arguments from run history fails due to incorrect quoting #129

Closed
2 tasks done
Ferdi265 opened this issue May 3, 2024 · 3 comments
Closed
2 tasks done
Labels

Comments

@Ferdi265
Copy link

Ferdi265 commented May 3, 2024

Rofi version (rofi -v or git commit in case of build issue)

1.7.5 wayland3-2

Configuration

(shown for completeness, config is /dev/null)
https://gist.github.com/Ferdi265/632b99b10f16440b3cdf43f8282b58cb

Theme

(shown for completeness, config is /dev/null)
https://gist.github.com/Ferdi265/632b99b10f16440b3cdf43f8282b58cb

Timing report

No response

Launch command

rofi -config /dev/null -show run

Step to reproduce

  • run powerprofilesctl set performance (note that the 'set', 'performance' arguments are extra arguments not part of the suggested commands)
  • observe that it works
  • run powerprofilesctl set performance again (note that it now finds this command in the history)
  • observe that it doesn't work due to incorrect quoting

Expected behavior

Running a command from history should behave the exact same was as running a command the first time.

Actual behavior

Rofi applies quoting to the command from history, resulting in rofi trying to find a command named 'powerprofilesctl set performance' (including quotes), which fails.

Additional information

The following patch fixes the immediate problem by avoiding shell quoting of the command arguments:

--- a/source/modes/run.c	2024-03-05 17:15:44.000000000  0100
    b/source/modes/run.c	2024-03-10 16:15:04.117103489  0100
@@ -449,11  449,11 @@
                                    &path);
       if (retv == MODE_EXIT) {
         if (path == NULL) {
-          char *arg = g_shell_quote(rmpd->cmd_list[rmpd->selected_line].entry);
           char *arg = rmpd->cmd_list[rmpd->selected_line].entry;
           exec_cmd(arg, run_in_term, rmpd->cmd_list[rmpd->selected_line].entry);
           g_free(arg);
         } else {
-          char *earg = g_shell_quote(rmpd->cmd_list[rmpd->selected_line].entry);
           char *earg = rmpd->cmd_list[rmpd->selected_line].entry;
           char *epath = g_shell_quote(path);
           char *arg = g_strdup_printf("%s %s", earg, epath);
           exec_cmd(arg, run_in_term, arg);
@@ -468,7  468,7 @@
   }
 
   if ((mretv & MENU_OK) && rmpd->cmd_list[selected_line].entry != NULL) {
-    char *earg = g_shell_quote(rmpd->cmd_list[selected_line].entry);
     char *earg = rmpd->cmd_list[selected_line].entry;
     if (!exec_cmd(earg, run_in_term, rmpd->cmd_list[selected_line].entry)) {
       retv = RELOAD_DIALOG;
     }

This patch works, and I've been using it on my system for weeks now, but I haven't worked on it a lot and there might be a better solution.

I'd be happy to work out a solution to this in more detail if required and can open a PR for this.

Note that this issue is specific to this fork, appeared rather recently, and doesn't occur with upstream rofi releases.

Using wayland display server protocol

  • Yes, I use rofi with wayland support

I've checked if the issue exists in the latest stable release

  • Yes, I have checked the problem exists in the latest stable version
@Ferdi265 Ferdi265 added the bug label May 3, 2024
@alebastr
Copy link

alebastr commented May 3, 2024

Should be fixed by davatorium@04f1605 and davatorium@1063b6e so another merge from upstream might be necessary.

@Ferdi265
Copy link
Author

Ferdi265 commented May 3, 2024

I can confirm that these upstream commits fix the issue when applied on top of the latest release.

@lbonn
Copy link
Owner

lbonn commented May 4, 2024

Ok I've updated the wayland branch, it should be fixed now.

@lbonn lbonn closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants