aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-03-10 14:05:42 +0100
committerClifford Wolf <clifford@clifford.at>2013-03-10 14:05:42 +0100
commiteadf73c823cc290ca4dcd1433f59808b70a2fad2 (patch)
tree3b8240d6ceb2ea33b653c830bdd099493c65a70c /kernel
parent0be19f6ca76b01892c09a05452de82f478d93f8f (diff)
downloadyosys-eadf73c823cc290ca4dcd1433f59808b70a2fad2.tar.gz
yosys-eadf73c823cc290ca4dcd1433f59808b70a2fad2.tar.bz2
yosys-eadf73c823cc290ca4dcd1433f59808b70a2fad2.zip
Added shell escape to command language
Diffstat (limited to 'kernel')
-rw-r--r--kernel/register.cc13
1 files changed, 13 insertions, 0 deletions
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 <assert.h>
#include <string.h>
+#include <stdlib.h>
using namespace REGISTER_INTERN;
#define MAX_REG_COUNT 1000
@@ -132,6 +133,18 @@ void Pass::call(RTLIL::Design *design, std::string command)
{
std::vector<std::string> 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();