implement bash specific var=() parsing
This commit is contained in:
parent
7d54b67b37
commit
9c2f3c91f9
2 changed files with 21 additions and 9 deletions
|
|
@ -25,11 +25,18 @@ bool debashify_array_def(cmd* in)
|
||||||
for(auto it: in->var_assigns)
|
for(auto it: in->var_assigns)
|
||||||
{
|
{
|
||||||
if(it.second->size()>0 && it.second->sa[0]->type == _obj::subarg_string && it.second->sa[0]->generate(0) == "(")
|
if(it.second->size()>0 && it.second->sa[0]->type == _obj::subarg_string && it.second->sa[0]->generate(0) == "(")
|
||||||
throw std::runtime_error("Cannot debashify VAR=() variable arrays");
|
throw std::runtime_error("Cannot debashify 'VAR=()' arrays");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool debashify_array_call(variable* in)
|
||||||
|
{
|
||||||
|
if(in->index != nullptr)
|
||||||
|
throw std::runtime_error("Cannot debashify 'VAR[I]' arrays");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool debashify_herestring(pipeline* pl)
|
bool debashify_herestring(pipeline* pl)
|
||||||
{
|
{
|
||||||
if(pl->cmds.size()>0)
|
if(pl->cmds.size()>0)
|
||||||
|
|
@ -87,13 +94,6 @@ bool debashify_combined_redirects(block* in)
|
||||||
return has_replaced;
|
return has_replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace <<< and
|
|
||||||
// <<< : TODO
|
|
||||||
bool debashify_extended_redirects(pipeline* in)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// replace <() and >()
|
// replace <() and >()
|
||||||
/*
|
/*
|
||||||
REPLACE TO:
|
REPLACE TO:
|
||||||
|
|
@ -192,6 +192,10 @@ bool r_debashify(_obj* o, bool* need_random_func)
|
||||||
{
|
{
|
||||||
switch(o->type)
|
switch(o->type)
|
||||||
{
|
{
|
||||||
|
case _obj::_variable: {
|
||||||
|
variable* t = dynamic_cast<variable*>(o);
|
||||||
|
debashify_array_call(t);
|
||||||
|
} break;
|
||||||
case _obj::_list: {
|
case _obj::_list: {
|
||||||
list* t = dynamic_cast<list*>(o);
|
list* t = dynamic_cast<list*>(o);
|
||||||
if(debashify_procsub(t))
|
if(debashify_procsub(t))
|
||||||
|
|
|
||||||
|
|
@ -1086,7 +1086,15 @@ std::pair<cmd*, uint32_t> parse_cmd(const char* in, uint32_t size, uint32_t star
|
||||||
vp.first->definition=true;
|
vp.first->definition=true;
|
||||||
i=vp.second+1;
|
i=vp.second+1;
|
||||||
arg* ta;
|
arg* ta;
|
||||||
if( is_in(in[i], ARG_END) ) // no value : give empty value
|
if(g_bash && in[i] == '(')
|
||||||
|
{
|
||||||
|
auto pp=parse_arg(in, size, i+1, ")");
|
||||||
|
ta=pp.first;
|
||||||
|
ta->insert(0, new string_subarg("(") );
|
||||||
|
ta->add(new string_subarg(")") );
|
||||||
|
i=pp.second+1;
|
||||||
|
}
|
||||||
|
else if( is_in(in[i], ARG_END) ) // no value : give empty value
|
||||||
{
|
{
|
||||||
ta = new arg;
|
ta = new arg;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue