File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -146,14 +146,16 @@ def main():
146
146
log .debug ('Saving sourcable %s hooks to %s' ,
147
147
hook , options .script_filename )
148
148
options .sourcing = True
149
- output = open (options .script_filename , "w" )
150
149
try :
151
- output .write ('# %s\n ' % hook )
152
- # output.write('echo %s\n' % hook)
153
- # output.write('set -x\n')
154
- run_hooks (hook + '_source' , options , args , output )
155
- finally :
156
- output .close ()
150
+ with open (options .script_filename , "w" ) as output :
151
+ output .write ('# %s\n ' % hook )
152
+ # output.write('echo %s\n' % hook)
153
+ # output.write('set -x\n')
154
+ run_hooks (hook + '_source' , options , args , output )
155
+ except (IOError , OSError ) as e :
156
+ log .error ('Error while writing to %s: \n %s' ,
157
+ options .script_filename , e )
158
+ sys .exit (1 )
157
159
158
160
return 0
159
161
You can’t perform that action at this time.
0 commit comments