Commit 6b5e16e5 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

added extra rule for apply when using cdo internal wildcards

parent 6b8b0f30
Pipeline #5025 passed with stages
in 16 minutes and 50 seconds
......@@ -104,9 +104,30 @@ expandWildCards(std::vector<std::string> argv)
int flags = WRDE_UNDEF;
wordexp_t glob_results;
bool applyActive = false;
int bracketsOpen = 0;
for (size_t idx = 1; idx < argv.size(); idx++)
{
// if argv[idx] contains wildcard (* or [?]+), multiple ** are ignored
if (argv[idx].compare(0, 6, "-apply") == 0)
{
applyActive = true;
continue;
}
if (argv[idx].size() == 1 && argv[idx][0] == '[')
{
bracketsOpen++;
continue;
}
if (argv[idx].size() == 1 && argv[idx][0] == ']')
{
bracketsOpen--;
if (bracketsOpen == 0)
{
applyActive = false;
}
continue;
}
if (argv[idx][0] != '-' && argv[idx].find_first_of("*?[ ") != std::string::npos)
{
const int status = wordexp(argv[idx].c_str(), &glob_results, flags);
......@@ -131,9 +152,14 @@ expandWildCards(std::vector<std::string> argv)
// range based insert (glob_results.we_wordv is inserted before wildcard
if (std::string(glob_results.we_wordv[0]).find_first_of("*?[ ") == std::string::npos)
{
argv.insert(argv.begin() + idx + 1, "]");
argv.insert(argv.begin() + idx + 1, "[");
argv.insert(argv.begin() + idx + 2, glob_results.we_wordv, glob_results.we_wordv + glob_results.we_wordc);
int insertAt = idx + 1;
if (applyActive == false)
{
argv.insert(argv.begin() + insertAt, "]");
argv.insert(argv.begin() + insertAt, "[");
insertAt+=1;
}
argv.insert(argv.begin() + insertAt, glob_results.we_wordv, glob_results.we_wordv + glob_results.we_wordc);
argv.erase(argv.begin() + idx);
}
// delete wildcard
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment