From: Clifford Wolf Date: Sun, 10 Mar 2013 13:05:42 +0000 (+0100) Subject: Added shell escape to command language X-Git-Tag: yosys-0.2.0~728 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eadf73c823cc290ca4dcd1433f59808b70a2fad2;p=yosys.git Added shell escape to command language --- diff --git a/kernel/register.cc b/kernel/register.cc index 0b0fb9f9c..5c9b40cd1 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -21,6 +21,7 @@ #include "log.h" #include #include +#include using namespace REGISTER_INTERN; #define MAX_REG_COUNT 1000 @@ -132,6 +133,18 @@ void Pass::call(RTLIL::Design *design, std::string command) { std::vector args; char *s = strdup(command.c_str()), *saveptr; + s += strspn(s, " \t\r\n"); + if (*s == 0 || *s == '#') + return; + if (*s == '!') { + for (s++; *s == ' ' || *s == '\t'; s++) { } + char *p = s + strlen(s) - 1; + while (p >= s && (*p == '\r' || *p == '\n')) + *(p--) = 0; + log_header("Shell command: %s\n", s); + system(s); + return; + } for (char *p = strtok_r(s, " \t\r\n", &saveptr); p; p = strtok_r(NULL, " \t\r\n", &saveptr)) { std::string str = p; int strsz = str.size();