Skip to content

Commit

Permalink
[Run] When passing raw entry, pass it unquoted to history
Browse files Browse the repository at this point in the history
fixes: #1951
  • Loading branch information
DaveDavenport committed Feb 27, 2024
1 parent eae65b2 commit ee1b68a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/modes/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef struct {
*
* Execute command and add to history.
*/
static gboolean exec_cmd(const char *cmd, int run_in_term) {
static gboolean exec_cmd(const char *cmd, int run_in_term, const char *orig) {
GError *error = NULL;
if (!cmd || !cmd[0]) {
return FALSE;
Expand All @@ -118,12 +118,12 @@ static gboolean exec_cmd(const char *cmd, int run_in_term) {
* It is allowed to be a bit slower.
*/

history_set(path, cmd);
history_set(path, orig);
g_free(path);
g_free(lf_cmd);
return TRUE;
}
history_remove(path, cmd);
history_remove(path, orig);
g_free(path);
g_free(lf_cmd);
return FALSE;
Expand Down Expand Up @@ -445,13 +445,13 @@ static ModeMode run_mode_result(Mode *sw, int mretv, char **input,
if (retv == MODE_EXIT) {
if (path == NULL) {
char *arg = g_shell_quote(rmpd->cmd_list[rmpd->selected_line].entry);
exec_cmd(arg, run_in_term);
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 *epath = g_shell_quote(path);
char *arg = g_strdup_printf("%s %s", earg, epath);
exec_cmd(arg, run_in_term);
exec_cmd(arg, run_in_term, arg);
g_free(arg);
g_free(earg);
g_free(epath);
Expand All @@ -464,13 +464,13 @@ static ModeMode run_mode_result(Mode *sw, int mretv, char **input,

if ((mretv & MENU_OK) && rmpd->cmd_list[selected_line].entry != NULL) {
char *earg = g_shell_quote(rmpd->cmd_list[selected_line].entry);
if (!exec_cmd(earg, run_in_term)) {
if (!exec_cmd(earg, run_in_term, rmpd->cmd_list[selected_line].entry)) {
retv = RELOAD_DIALOG;
}
g_free(earg);
} else if ((mretv & MENU_CUSTOM_INPUT) && *input != NULL &&
*input[0] != '\0') {
if (!exec_cmd(*input, run_in_term)) {
if (!exec_cmd(*input, run_in_term, *input)) {
retv = RELOAD_DIALOG;
}
} else if ((mretv & MENU_ENTRY_DELETE) &&
Expand Down

0 comments on commit ee1b68a

Please sign in to comment.