diff --git a/include/struc.hpp b/include/struc.hpp index d415514..6f32a61 100644 --- a/include/struc.hpp +++ b/include/struc.hpp @@ -287,12 +287,13 @@ public: class pipeline_t : public _obj { public: - pipeline_t(block_t* bl=nullptr) { type=_obj::pipeline; if(bl!=nullptr) cmds.push_back(bl); negated=false; } + pipeline_t(block_t* bl=nullptr) { type=_obj::pipeline; if(bl!=nullptr) cmds.push_back(bl); negated=false; bash_time=false; } ~pipeline_t() { for(auto it: cmds) delete it; } inline void add(block_t* bl) { this->cmds.push_back(bl); } std::vector cmds; bool negated; // negated return value (! at start) + bool bash_time; // has bash time command std::string generate(int ind, generate_context* ctx); std::string generate(int ind) { return this->generate(ind, nullptr); }; diff --git a/src/generate.cpp b/src/generate.cpp index 1865bbf..557bfcc 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -56,6 +56,10 @@ std::string pipeline_t::generate(int ind, generate_context* ctx) if(negated) ret += "! "; + + if(bash_time) + ret += "time "; + ret += cmds[0]->generate(ind, ctx); for(uint32_t i=1 ; i parse_pipeline(parse_context ctx) { pipeline_t* ret = new pipeline_t; - if(ctx[ctx.i] == '!' && ctx.i+1negated = true; - ctx.i++; - ctx.i=skip_chars(ctx, SPACES); + while(true) { + auto wp = get_word(ctx, ARG_END); + if(ctx[ctx.i] == '!' && ctx.i+1negated = ret->negated ? false : true; + ctx.i++; + ctx.i=skip_chars(ctx, SPACES); + } else if(ctx.bash && wp.first == "time" ) { + ret->bash_time = true; + ctx.i+=4; + ctx.i=skip_chars(ctx, SPACES); + } else { + break; + } } + while(ctx.i