Skip to content

Commit

Permalink
Fixed not being able to run multiple commands regression by #519
Browse files Browse the repository at this point in the history
Thanks @jbeich for finding this bug
  • Loading branch information
ErikReider committed Mar 3, 2025
1 parent 046e895 commit d0998d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/functions.vala
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ namespace SwayNotificationCenter {
}

string[] argvp;
Shell.parse_argv ("/bin/sh -c %s".printf (cmd), out argvp);
Shell.parse_argv ("/bin/sh -c \"%s\"".printf (cmd), out argvp);

Pid child_pid;
int std_output;
Expand All @@ -381,13 +381,17 @@ namespace SwayNotificationCenter {
return false;
}
try {
channel.read_line (out res, null, null);
if (channel.read_line (out res, null, null) == IOStatus.NORMAL) {
debug ("Exec output:\n%s", res);
} else {
res = "";
}
return true;
} catch (IOChannelError e) {
stderr.printf ("stdout: IOChannelError: %s\n", e.message);
warning ("stdout: IOChannelError: %s", e.message);
return false;
} catch (ConvertError e) {
stderr.printf ("stdout: ConvertError: %s\n", e.message);
warning ("stdout: ConvertError: %s", e.message);
return false;
}
});
Expand All @@ -400,12 +404,12 @@ namespace SwayNotificationCenter {
end_status = status;
execute_command.callback ();
});
// Waits until `run_script.callback()` is called above
// Waits until `execute_command.callback()` is called above
yield;
msg = res;
return end_status == 0;
} catch (Error e) {
stderr.printf ("Run_Script Error: %s\n", e.message);
warning ("Execute Command Error: %s", e.message);
msg = e.message;
return false;
}
Expand Down

0 comments on commit d0998d0

Please sign in to comment.