File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,18 @@ function mount_file() {
259259    mounts+=(" -v" " ${file_on_host} :${file_in_container} :${mount_option} " 
260260}
261261
262+ #  Clean up the token file and EXIT this bash script with the given status code.
263+ # 
264+ #  Arguments:
265+ #    $1: The eventual exit status code.
266+ #    $2: The path to the token file.
267+ function  clean_up_exit()  {
268+     status_code=$1 
269+     token_file_path=$2 
270+     rm -f " $token_file_path " 
271+     exit  " $status_code " 
272+ }
273+ 
262274#  Parse main arguments.
263275while  [[ $#  -gt  0 ]];  do 
264276    case  $1  in 
@@ -599,7 +611,7 @@ mount_file "macaron_env_file" ${TOKEN_FILE} ${MACARON_WORKSPACE}/${TOKEN_FILE} "
599611set  -u
600612
601613#  Force docker to use linux/amd64 platform in order to make docker use emulation on ARM host platforms.
602- #  We need the `docker run` command to be within `set +e``  so that when it returns a non-zero status code,
614+ #  We need the `docker run` command to be within `set +e` so that when it returns a non-zero status code,
603615#  it doesn't exit right away and still run the token file cleaning up command.
604616set  +e
605617docker run \
@@ -614,6 +626,5 @@ docker run \
614626    " ${IMAGE} :${MACARON_IMAGE_TAG} " 
615627    " ${entrypoint[@]} " 
616628    " ${macaron_args[@]} " 
617- set  -e
618629
619- rm -f  " $TOKEN_FILE " 
630+ clean_up_exit  " $? " " $TOKEN_FILE " 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments