implement bash specific ${!var}
This commit is contained in:
parent
06eac33b0a
commit
f5e5d32eca
2 changed files with 17 additions and 2 deletions
|
|
@ -766,12 +766,23 @@ bool debashify_procsub(list* lst, debashify_params* params)
|
|||
return has_replaced;
|
||||
}
|
||||
|
||||
bool debashify_var(variable* in, debashify_params* params)
|
||||
{
|
||||
if(in->is_manip && in->precedence && in->manip->string() == "!")
|
||||
throw std::runtime_error("Cannot debashify ${!VAR}");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool r_debashify(_obj* o, debashify_params* params)
|
||||
{
|
||||
// global debashifies
|
||||
debashify_array_arithmetic(o, params);
|
||||
switch(o->type)
|
||||
{
|
||||
case _obj::_variable: {
|
||||
variable* t = dynamic_cast<variable*>(o);
|
||||
debashify_var(t, params);
|
||||
} break;
|
||||
case _obj::_arg: {
|
||||
arg* t = dynamic_cast<arg*>(o);
|
||||
debashify_array_get(t, params);
|
||||
|
|
|
|||
|
|
@ -282,9 +282,13 @@ std::pair<variable*, uint32_t> parse_manipulation(const char* in, uint32_t size,
|
|||
{
|
||||
#endif
|
||||
;
|
||||
if(in[i] == '#')
|
||||
if(in[i] == '#' || in[i] == '!')
|
||||
{
|
||||
precede = new arg("#");
|
||||
if(!g_bash && in[i] == '!')
|
||||
throw PARSE_ERROR("bash specific: '${!}'", i);
|
||||
std::string t;
|
||||
t+=in[i];
|
||||
precede = new arg( t );
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue