[PATCH] tester/rt: use shlex.split to split command args

Muhammad Sulthan Mazaya msulthanmazaya at gmail.com
Mon May 22 12:37:40 UTC 2023


The regular split-by-space function used to split command arguments 
creates compatibility issues with many shell command syntaxes. A 
specific example is the handling of string arguments, as shown below:

%define renode_args -e start_opts -e "s %{bsp_resc_script}"

Thus, it is changed to use shlex.split instead. It splits 
the command arguments using shell-like syntax. More about shlex 
module here: https://docs.python.org/3/library/shlex.html 

---
 tester/rt/config.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tester/rt/config.py b/tester/rt/config.py
index 8a433af..bf6fdbf 100644
--- a/tester/rt/config.py
+++ b/tester/rt/config.py
@@ -38,6 +38,7 @@ import datetime
 import os
 import re
 import threading
+import shlex
 
 from rtemstoolkit import configuration
 from rtemstoolkit import config
@@ -326,7 +327,7 @@ class file(config.file):
             if len(_data):
                 ds = [_data[0]]
                 if len(_data) > 1:
-                    ds += _data[1].split()
+                    ds += shlex.split(_data[1], posix=False)
             ds = self.expand(ds)
 
             if _directive == '%console':
-- 
2.34.1



More information about the devel mailing list