0

I have this script:

#!/bin/bash

date="20180313"
source_path="/Users/<user_name>/Source/Git/WSI"
installer_path="../FE_Installer/cdk_installer/*"

echo "archive=$source_path/wsi_installers_$date.zip"
echo "path=$installer_path"

# Create the installer archive
zip -r "$source_path/wsi_installers_$date.zip" "$installer_path"

If the archive does not exist, it fails with:

zip warning: name not matched: ../FE_Installer/cdk_installer/*
zip error: Nothing to do! (try: zip -r /Users/<user_name>/Source/Git/WSI/wsi_installers_20180313.zip . -i ../FE_Installer/cdk_installer/*)

Though the echo statements indicate a correct path:

archive=/Users/<user_name>/Source/Git/WSI/wsi_installers_20180313.zip
path=../FE_Installer/cdk_installer/*

I tried the recommended command (using the -i option) but it fails with:

zip warning: zip file empty

If I use the output from the echo statements and run the zip command manually:

zip -r /Users/<user_name>/Source/Git/WSI/wsi_installers_20180313.zip ../FE_Installer/cdk_installer/*

It works:

adding: ../FE_Installer/cdk_installer/ADP_Installers.hta (deflated 71%)
adding: ../FE_Installer/cdk_installer/StartHta.exe (deflated 71%)
adding: ../FE_Installer/cdk_installer/WSPCP_TDI/ (stored 0%)
...
adding: ../FE_Installer/cdk_installer/common/styles/plugins.css (deflated 85%)
adding: ../FE_Installer/cdk_installer/common/styles/table.css (deflated 80%)
adding: ../FE_Installer/cdk_installer/updatecenter/ (stored 0%)

Then when I run the script, it also works, with the output showing it is updating the archive:

updating: ../FE_Installer/cdk_installer/ADP_Installers.hta (deflated 71%)
updating: ../FE_Installer/cdk_installer/StartHta.exe (deflated 71%)
updating: ../FE_Installer/cdk_installer/WSPCP_TDI/ (stored 0%)
...
updating: ../FE_Installer/cdk_installer/common/styles/plugins.css (deflated 85%)
updating: ../FE_Installer/cdk_installer/common/styles/table.css (deflated 80%)
updating: ../FE_Installer/cdk_installer/updatecenter/ (stored 0%)

What am I missing?

5
  • Add set -x to your script. That'll show what it thinks is happening.
    – RonJohn
    Mar 14 '18 at 15:27
  • I bet the * in installer_path isn't getting expanded.
    – RonJohn
    Mar 14 '18 at 15:30
  • + zip -r /Users/barnesr/Source/Git/WSI/wsi_installers_20180313.zip '../FE_Installer/cdk_installer/*' zip warning: name not matched: ../FE_Installer/cdk_installer/* zip error: Nothing to do! (try: zip -r /Users/barnesr/Source/Git/WSI/wsi_installers_20180313.zip . -i ../FE_Installer/cdk_installer/*) + exit
    – IronRod
    Mar 14 '18 at 15:30
  • I suspected the '*' was a factor -- but why would it work when the ZIP exists?
    – IronRod
    Mar 14 '18 at 15:32
  • Removing the '*' was the solution. Thanks. Add it as an answer and I'll mark it.
    – IronRod
    Mar 14 '18 at 15:33
1

I bet the * in installer_path isn't getting expanded. Take the * out of installer_path and it'll work.

2
  • This doesn't explain why, it works, which is because the * was quoted, so zip was looking for literal file/dir named *. You can put asterisks immediately after quoted parameters to retain shell globbing.
    – Walf
    Jun 15 '20 at 4:44
  • @Walf that's mentioned in a comment I made to the question, before making an official answer. I'll add it to the answer for clarity.
    – RonJohn
    Jun 15 '20 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.