Skip to content

Commit

Permalink
Make unquoting logic in "set" more cmd-like
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jan 21, 2025
1 parent 064cc9f commit 8e9702c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 2025-01-21 20:58:50+00:00 - build 6420

1. Make unquoting logic in "set" more cmd-like.

--------------------------------------------------------------------------------
drkns 2025-01-19 22:00:05+00:00 - build 6419

Expand Down
14 changes: 13 additions & 1 deletion far/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,20 @@ bool CommandLine::ProcessOSCommands(string_view const CmdLine, function_ref<void
if (FindKey(Arguments, L'A') || FindKey(Arguments, L'P'))
return false; //todo: /p - dialog, /a - calculation; then set variable ...

// cmd unquoting logic is rather weird, but when in Rome, do as the Romans do.
const auto set_unquote = [](string_view Str)
{
if (!Str.starts_with(L'"'))
return Str;

Str.remove_prefix(1);
inplace::trim_left(Str);

return Str.substr(0, Str.rfind(L'"'));
};

size_t pos;
const auto SetParams = unquote(trim_right(Arguments));
const auto SetParams = set_unquote(trim_right(Arguments));

// "set" (display all) or "set var" (display all that begin with "var")
if (SetParams.empty() || ((pos = SetParams.find(L'=')) == string::npos) || !pos)
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6419
6420

0 comments on commit 8e9702c

Please sign in to comment.