Skip to content

Commit

Permalink
Restored substition of aliases in terminal commands
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed Apr 9, 2024
1 parent 3b57e3f commit 63edf61
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Fixed input timeouts on Linux (#91).
- Fixed ContextActive with output on release (#91).
- Restored substition of aliases in terminal commands (#91).
- Fixed error notifications on Linux.

## [Version 4.0.0] - 2024-03-28
Expand Down
16 changes: 1 addition & 15 deletions src/config/ParseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,20 +501,6 @@ std::string ParseConfig::preprocess(It it, const It end) const {

result.append(begin, it);
}
else if (skip(&it, end, "$(")) {
// a terminal command
for (auto level = 1; level > 0; ) {
if (it == end)
error("Unterminated terminal command");
if (skip(&it, end, '('))
++level;
else if (skip(&it, end, ')'))
--level;
else
++it;
}
result.append(begin, it);
}
else {
// single character
result.append(begin, ++it);
Expand Down Expand Up @@ -661,4 +647,4 @@ void ParseConfig::optimize_contexts() {
}
}
}
}
}
5 changes: 3 additions & 2 deletions src/test/test1_ParseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,13 @@ TEST_CASE("Macros with Terminal Commands", "[ParseConfig]") {
REQUIRE(config.actions.size() == 6);

CHECK(config.actions[0].terminal_command == R"(notify-send -t 2000 -a "keymapper" "F7")");
// in $() and strings only $0... are substituted
// in strings only $0... are substituted
CHECK(config.actions[1].terminal_command == R"(echo $(echo $0$1))");
CHECK(config.actions[2].terminal_command == R"(echo echo )");
CHECK(config.actions[3].terminal_command == R"(echo echo, echo)");
CHECK(config.actions[4].terminal_command == R"(echo echo echo )");
CHECK(config.actions[5].terminal_command == R"(echo "echo")");
// in terminal commands macros are also substituted
CHECK(config.actions[5].terminal_command == R"($(echo $0$1) "echo")");
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 63edf61

Please sign in to comment.