From d5d02280c123b8849fff3b2a542a6ab2a818aca8 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 27 Sep 2022 00:21:37 +0200 Subject: [PATCH] Fix download-boxes.sh if no boxes are present (#106) In case of grep not matching any line, it would return an error code and thus stop the script. This patch sets "present_boxes" to an empty value in case any of the commands fail. --- .github/download-boxes.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/download-boxes.sh b/.github/download-boxes.sh index fb5bf8e..d62261d 100755 --- a/.github/download-boxes.sh +++ b/.github/download-boxes.sh @@ -17,11 +17,14 @@ all_boxes=$(cat "${GIT_ROOT}"/molecule/*/molecule.yml | uniq) # Read the boxes that are currently present on the system (for the current provider) -present_boxes=$(vagrant box list | - grep "${PROVIDER}" | # Filter by boxes available for the current provider - awk '{print $1;}' | # The box name is the first word in each line - sort | - uniq) +present_boxes=$( + (vagrant box list | + grep "${PROVIDER}" | # Filter by boxes available for the current provider + awk '{print $1;}' | # The box name is the first word in each line + sort | + uniq) || + echo "" # In case any of these commands fails, just use an empty list +) # The boxes that we need to download are the ones present in $all_boxes, but not $present_boxes. download_boxes=$(comm -2 -3 <(echo "${all_boxes}") <(echo "${present_boxes}"))