@@ -208,11 +208,8 @@ def map_line_from_source_file(source_filename, source_line_num,
208
208
209
209
def read_response_file (file_path ):
210
210
with open (file_path , 'r' ) as files :
211
- # "Make an iterator out of shlex.shlex.get_token, then consume items
212
- # until it returns None." (Then eagerly convert the result to a list so
213
- # that we can close the file.)
214
- return list (iter (shlex .shlex (files , file_path , posix = True ).get_token ,
215
- None ))
211
+ # Read a response file and return a list of files (one per line).
212
+ return [line .strip () for line in files if line .strip ()]
216
213
217
214
218
215
def expand_response_files (files ):
@@ -683,16 +680,21 @@ def run():
683
680
# delegates to the Win32 CreateProcess API. Unix systems handle
684
681
# non-normalized paths, so don't have this problem.
685
682
# Arguments passed to the process are normalized by the process.
686
- command_args = expand_response_files ( sys .argv [dashes + 1 :])
683
+ command_args = sys .argv [dashes + 1 :]
687
684
command_args [0 ] = os .path .normpath (command_args [0 ])
688
685
689
- command = subprocess .Popen (
690
- command_args ,
691
- stderr = subprocess .STDOUT ,
692
- stdout = subprocess .PIPE ,
693
- universal_newlines = True ,
694
- encoding = 'UTF-8'
695
- )
686
+ try :
687
+ command = subprocess .Popen (
688
+ command_args ,
689
+ stderr = subprocess .STDOUT ,
690
+ stdout = subprocess .PIPE ,
691
+ universal_newlines = True ,
692
+ encoding = 'UTF-8'
693
+ )
694
+ except Exception as e :
695
+ sys .stderr .write (f"Error executing command: { e } \n " )
696
+ sys .stderr .write (f"Command: { ' ' .join (shlex .quote (arg ) for arg in command_args )} \n " )
697
+ sys .exit (1 )
696
698
697
699
sources = '(?P<file>' + '|' .join (re .escape (s ) for s in sources ) + ')'
698
700
@@ -731,7 +733,12 @@ def run():
731
733
m .group ('tail' ))
732
734
sys .stdout .write (output )
733
735
734
- sys .exit (command .wait ())
736
+ exit_code = command .wait ()
737
+ if exit_code != 0 :
738
+ sys .stderr .write (f"Command failed with exit code { exit_code } \n " )
739
+ sys .stderr .write (f"Command: { ' ' .join (shlex .quote (arg ) for arg in command_args )} \n " )
740
+
741
+ sys .exit (exit_code )
735
742
736
743
737
744
if __name__ == '__main__' :
0 commit comments