意外行为:bash 中的 zip -r

意外行为:bash 中的 zip -r

我有这个脚本:

#!/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"

如果存档不存在,则会失败并显示:

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/*)

尽管 echo 语句指示了正确的路径:

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

我尝试了推荐的命令(使用 -i 选项),但失败并显示:

zip warning: zip file empty

如果我使用 echo 语句的输出并手动运行 zip 命令:

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

有用:

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%)

然后,当我运行脚本时,它也可以工作,输出显示它正在更新存档:

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%)

我缺少什么?

答案1

我敢打赌,*ininstaller_path不会被扩展。把它拿出*installer_path就可以了。

相关内容