Skip to content

Commit

Permalink
options: implement ExpandPath transformer
Browse files Browse the repository at this point in the history
For expanding shell options (with expand_path / wordexp)

Note that e.g. in zsh: --maildir=~/Maildir is handled (program receives
--maildir=/home/user/Maildir) but e.g. bash does not do that, and the
program receives the literal '~/Maildir'

We expanded this in mu earlier, so let's do that again.
  • Loading branch information
djcb committed Aug 2, 2023
1 parent d25d4b0 commit c36d30b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mu/mu-options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <unistd.h>

#include <utils/mu-utils.hh>
#include <utils/mu-utils-file.hh>
#include <utils/mu-error.hh>
#include "utils/mu-test-utils.hh"
#include "mu-options.hh"
Expand Down Expand Up @@ -136,6 +137,19 @@ options_map(const IE& ie)
return map;
}



// transformers


// Expand the path using wordexp
static const std::function ExpandPath = [](std::string filepath)->std::string {
if (auto&& res{expand_path(filepath)}; !res)
throw CLI::ValidationError{res.error().what()};
else
return filepath = std::move(res.value());
};

/*
* common
*/
Expand Down

0 comments on commit c36d30b

Please sign in to comment.