5

I have a zip file which is compressed on a windows server and has the windows directory structure.

I am trying to uncompress the file on an ubuntu server with the command:

/tmp/temp » unzip -d /tmp/temp/temp backup.zip  

The unzipping works fine, the directory structure is converted into a Linux based one automatically. But due to some reason whatsoever the exit code of the extract command is 1 and this is messing up my Jenkins job, which is not proceeding further.

  inflating: /tmp/temp/temp/fs/site/wwwroot/vendor-a2341eb904.js  
  inflating: /tmp/temp/temp/fs/site/wwwroot/vendor-fc433e18b6.css  
  inflating: /tmp/temp/temp/fs/site/wwwroot/web.config  
  inflating: /tmp/temp/temp/meta     
------------------------------------------------------------
/tmp/temp » echo $?                                                                                                                                                
1

I even tested the archive to compare the CRC of the extracted file with the one in the archive and it seems to be allright:

    testing: fs\site\wwwroot\vendor-fc433e18b6.css   OK
    testing: fs\site\wwwroot\web.config   OK
    testing: meta                     OK
No errors detected in compressed data of backup.zip.
------------------------------------------------------------
/tmp/temp » echo $?                                                                                                                                               
0

Any idea what might be the cause of return code 1 in the unzip command?

BTW: I also tried to set +e in my jenkins job to disregard the exit codes, but that didn't do any help.

Spaniard89
  • 2,359
  • 4
  • 34
  • 55
  • The main purpose of exit codes is to be able to use these utilities in a script or external program that performs with error checking. I don't see how that is off-topic to programming and development. – Alicia Feb 04 '18 at 12:20
  • This link provides related workarounds: https://stackoverflow.com/questions/38721876/make-unzip-try-to-unzip-files-if-they-exist-without-failure-if-not – ChoKaPeek Aug 11 '21 at 14:43

2 Answers2

4

Check with -v option if any file has been skipped

The man page for unzip states following for return value 1

one or more warning errors were encountered, but processing completed successfully anyway. This includes zipfiles where one or more files was skipped due to unsupported compression method or encryption with an unknown password.

deimus
  • 9,565
  • 12
  • 63
  • 107
1

If you are facing this issue and it is causing your shell script to end abruptly without errors, Check if your shell script file has set -e command at the top.

Set -e will end your script if any errors are thrown by any of the executing lines.

Unzip exit with error code in many scenarios even when there exist a non-critical warning and unzipping is successful.

AnandShiva
  • 906
  • 11
  • 22