Skip to content

Commit

Permalink
Fix download-boxes.sh if no boxes are present (techno-tim#106)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sleiner committed Sep 26, 2022
1 parent 57e5288 commit d5d0228
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .github/download-boxes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"))
Expand Down

0 comments on commit d5d0228

Please sign in to comment.