From e7613241c691504dab49c2f9d5efa6c8d404cb5b Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Thu, 13 Sep 2018 15:30:50 +0200
Subject: [PATCH] [Interpreter] Ignore empty command and Python comments.

---
 src/interpreter.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/interpreter.cc b/src/interpreter.cc
index b2c4cc8..9abf3c2 100644
--- a/src/interpreter.cc
+++ b/src/interpreter.cc
@@ -185,6 +185,13 @@ void Interpreter::python( const std::string& command, std::string& res,
   out = "";
   err = "";
 
+  // Check if the command is not a python comment or empty.
+  std::string::size_type iFirstNonWhite = command.find_first_not_of (" \t");
+  // Empty command
+  if (iFirstNonWhite == std::string::npos) return;
+  // Command is a comment. Ignore it.
+  if (command[iFirstNonWhite] == '#') return;
+
   PyEval_RestoreThread(_pyState);
 
   std::cout << command.c_str() << std::endl;
-- 
GitLab