@@ -60,7 +60,7 @@ def run_cmd_subprocess(command, verbose=False, cwd=None, encoding=sys.stdout.enc
6060 print ("Parent process:" , parent_process )
6161
6262 process = subprocess .Popen (
63- command ,
63+ process_multiline_command ( command ) ,
6464 stdout = subprocess .PIPE ,
6565 stderr = subprocess .STDOUT ,
6666 text = True ,
@@ -131,3 +131,27 @@ def output_callback(b):
131131 except (pexpect .ExceptionPexpect , TypeError , ValueError ) as e :
132132 error_msg = f"Error running command { command } : { e } "
133133 return 1 , error_msg
134+
135+
136+ def process_multiline_command (command_string ):
137+ """
138+ Removes lines that end with a single backslash used for line continuation.
139+ """
140+ lines = command_string .splitlines ()
141+ processed_lines = []
142+
143+ for line in lines :
144+ # rstrip() removes trailing whitespace, including newlines in the original splitlines context.
145+ # We check if the line, stripped of whitespace, ends with a single backslash.
146+ stripped_line = line .rstrip ()
147+
148+ # We need to distinguish between 'foo\' and 'foo\\' (literal backslash)
149+ if stripped_line .endswith ("\\ " ) and not stripped_line .endswith ("\\ \\ " ):
150+ # This line ends in an unescaped backslash (line continuation), so we skip it.
151+ continue
152+ else :
153+ processed_lines .append (line )
154+
155+ # Join the remaining lines with the appropriate newline character
156+ # Use '\n'.join for consistent Unix-style newlines, or os.linesep
157+ return "\n " .join (processed_lines )
0 commit comments