From b4a3767a189145d62177182fdd418bb3ba5dd455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Tue, 9 May 2017 01:20:50 +0200 Subject: Expand shell globs in input params --- drumgizmo/drumgizmoc.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index 6ee0905..feae0ae 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -261,11 +262,19 @@ int main(int argc, char* argv[]) std::string parm; std::string val; bool inval = false; + wordexp_t exp_result; for(size_t i = 0; i < iparms.size(); ++i) { if(iparms[i] == ',') { - ie->setParm(parm, val); + int error = wordexp(val.data(), &exp_result, 0); + if(error) + { + std::cerr << "Wrong argument: "; + std::cerr << parm << " = " << val << std::endl; + return 1; + } + ie->setParm(parm, exp_result.we_wordv[0]); parm = ""; val = ""; inval = false; @@ -289,7 +298,14 @@ int main(int argc, char* argv[]) } if(parm != "") { - ie->setParm(parm, val); + int error = wordexp(val.data(), &exp_result, 0); + if(error) + { + std::cerr << "Wrong argument: "; + std::cerr << parm << " = " << val << std::endl; + return 1; + } + ie->setParm(parm, exp_result.we_wordv[0]); } } -- cgit v1.2.3