@@ -211,8 +211,7 @@ def read_response_file(file_path):
211
211
# "Make an iterator out of shlex.shlex.get_token, then consume items
212
212
# until it returns None." (Then eagerly convert the result to a list so
213
213
# that we can close the file.)
214
- return list (iter (shlex .shlex (files , file_path , posix = True ).get_token ,
215
- None ))
214
+ return [line .strip () for line in files if line .strip ()]
216
215
217
216
218
217
def expand_response_files (files ):
@@ -686,13 +685,18 @@ def run():
686
685
command_args = expand_response_files (sys .argv [dashes + 1 :])
687
686
command_args [0 ] = os .path .normpath (command_args [0 ])
688
687
689
- command = subprocess .Popen (
690
- command_args ,
691
- stderr = subprocess .STDOUT ,
692
- stdout = subprocess .PIPE ,
693
- universal_newlines = True ,
694
- encoding = 'UTF-8'
695
- )
688
+ try :
689
+ command = subprocess .Popen (
690
+ command_args ,
691
+ stderr = subprocess .STDOUT ,
692
+ stdout = subprocess .PIPE ,
693
+ universal_newlines = True ,
694
+ encoding = 'UTF-8'
695
+ )
696
+ except Exception as e :
697
+ sys .stderr .write (f"Error executing command: { e } \n " )
698
+ sys .stderr .write (f"Command: { ' ' .join (shlex .quote (arg ) for arg in command_args )} \n " )
699
+ sys .exit (1 )
696
700
697
701
sources = '(?P<file>' + '|' .join (re .escape (s ) for s in sources ) + ')'
698
702
@@ -731,7 +735,12 @@ def run():
731
735
m .group ('tail' ))
732
736
sys .stdout .write (output )
733
737
734
- sys .exit (command .wait ())
738
+ exit_code = command .wait ()
739
+ if exit_code != 0 :
740
+ sys .stderr .write (f"Command failed with exit code { exit_code } \n " )
741
+ sys .stderr .write (f"Command: { ' ' .join (shlex .quote (arg ) for arg in command_args )} \n " )
742
+
743
+ sys .exit (exit_code )
735
744
736
745
737
746
if __name__ == '__main__' :
0 commit comments