|
Lines 280-286
my_system(const char *command)
Link Here
|
| 280 |
bool |
280 |
bool |
| 281 |
action::do_action(config &c) |
281 |
action::do_action(config &c) |
| 282 |
{ |
282 |
{ |
| 283 |
string s = c.expand_string(_cmd.c_str()); |
283 |
string s = c.expand_string(_cmd.c_str(), true); |
| 284 |
devdlog(LOG_INFO, "Executing '%s'\n", s.c_str()); |
284 |
devdlog(LOG_INFO, "Executing '%s'\n", s.c_str()); |
| 285 |
my_system(s.c_str()); |
285 |
my_system(s.c_str()); |
| 286 |
return (true); |
286 |
return (true); |
|
Lines 289-295
action::do_action(config &c)
Link Here
|
| 289 |
match::match(config &c, const char *var, const char *re) : |
289 |
match::match(config &c, const char *var, const char *re) : |
| 290 |
_inv(re[0] == '!'), |
290 |
_inv(re[0] == '!'), |
| 291 |
_var(var), |
291 |
_var(var), |
| 292 |
_re(c.expand_string(_inv ? re + 1 : re, "^", "$")) |
292 |
_re(c.expand_string(_inv ? re + 1 : re, false, "^", "$")) |
| 293 |
{ |
293 |
{ |
| 294 |
regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); |
294 |
regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); |
| 295 |
} |
295 |
} |
|
Lines 666-672
config::shell_quote(const string &s)
Link Here
|
| 666 |
} |
666 |
} |
| 667 |
|
667 |
|
| 668 |
void |
668 |
void |
| 669 |
config::expand_one(const char *&src, string &dst) |
669 |
config::expand_one(const char *&src, string &dst, bool squote) |
| 670 |
{ |
670 |
{ |
| 671 |
int count; |
671 |
int count; |
| 672 |
string buffer; |
672 |
string buffer; |
|
Lines 705-715
config::expand_one(const char *&src, string &dst)
Link Here
|
| 705 |
do { |
705 |
do { |
| 706 |
buffer += *src++; |
706 |
buffer += *src++; |
| 707 |
} while (is_id_char(*src)); |
707 |
} while (is_id_char(*src)); |
| 708 |
dst.append(shell_quote(get_variable(buffer))); |
708 |
if (squote) |
|
|
709 |
dst.append(shell_quote(get_variable(buffer))); |
| 710 |
else |
| 711 |
dst.append(get_variable(buffer)); |
| 709 |
} |
712 |
} |
| 710 |
|
713 |
|
| 711 |
const string |
714 |
const string |
| 712 |
config::expand_string(const char *src, const char *prepend, const char *append) |
715 |
config::expand_string(const char *src, bool squote, const char *prepend, |
|
|
716 |
const char *append) |
| 713 |
{ |
717 |
{ |
| 714 |
const char *var_at; |
718 |
const char *var_at; |
| 715 |
string dst; |
719 |
string dst; |
|
Lines 731-737
config::expand_string(const char *src, const char *prepend, const char *append)
Link Here
|
| 731 |
} |
735 |
} |
| 732 |
dst.append(src, var_at - src); |
736 |
dst.append(src, var_at - src); |
| 733 |
src = var_at; |
737 |
src = var_at; |
| 734 |
expand_one(src, dst); |
738 |
expand_one(src, dst, squote); |
| 735 |
} |
739 |
} |
| 736 |
|
740 |
|
| 737 |
if (append != NULL) |
741 |
if (append != NULL) |