mirror of
https://github.com/swaywm/sway.git
synced 2025-02-17 14:54:27 +00:00
cmd: fix input/output unstripped definition quotes
With the following config: set $abc "wayland wayland " set $def "0:0:wayland-seat0" The following command would fail to be executed: swaymsg -- output '$abc' scale 2 swaymsg -- input '$def' repeat_rate 2 The definition `$abc` is replaced with its content, including the quotes, which fails to match real output names. Same for `$def` We now strip quotes early in the output command. The behaviour was inconsistent between config_command() and execute_command(). * config_command() strips quotes before do_var_replacement() and also after, under some conditions. * execute_command() strips them only before. execute_command() is run after receiving swaymsg command hence the failing example mentioned above. Since we now strip quotes in cmd_output and cmd_input we prevent config_command() from stripping them twice.
This commit is contained in:
parent
97adba0516
commit
7461473918
|
@ -403,6 +403,8 @@ struct cmd_results *config_command(char *exec, char **new_block) {
|
||||||
&& handler->handle != cmd_bindswitch
|
&& handler->handle != cmd_bindswitch
|
||||||
&& handler->handle != cmd_set
|
&& handler->handle != cmd_set
|
||||||
&& handler->handle != cmd_for_window
|
&& handler->handle != cmd_for_window
|
||||||
|
&& handler->handle != cmd_output
|
||||||
|
&& handler->handle != cmd_input
|
||||||
&& (*argv[i] == '\"' || *argv[i] == '\'')) {
|
&& (*argv[i] == '\"' || *argv[i] == '\'')) {
|
||||||
strip_quotes(argv[i]);
|
strip_quotes(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,13 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commands from config_command() & execute_command() don't handle quotes the same way
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
if (*argv[i] == '\"' || *argv[i] == '\'') {
|
||||||
|
strip_quotes(argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "entering input block: %s", argv[0]);
|
sway_log(SWAY_DEBUG, "entering input block: %s", argv[0]);
|
||||||
|
|
||||||
config->handler_context.input_config = new_input_config(argv[0]);
|
config->handler_context.input_config = new_input_config(argv[0]);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
|
#include "stringop.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
@ -39,6 +40,13 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
"Refusing to configure the no op output");
|
"Refusing to configure the no op output");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commands from config_command() & execute_command() don't handle quotes the same way
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
if (*argv[i] == '\"' || *argv[i] == '\'') {
|
||||||
|
strip_quotes(argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct output_config *output = NULL;
|
struct output_config *output = NULL;
|
||||||
if (strcmp(argv[0], "-") == 0 || strcmp(argv[0], "--") == 0) {
|
if (strcmp(argv[0], "-") == 0 || strcmp(argv[0], "--") == 0) {
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
|
|
Loading…
Reference in a new issue