Skip to content

Commit 18512cd

Browse files
committed
Handle missing ${name} in .tool-versions (fallback to "lastest")
With set -euo pipefail, this grep | ... | grep pipeline will terminate the script when there is no matching docker/${name} entry in .tool-versions (a normal case). The command substitution should tolerate no matches and fall back to latest.
1 parent 5eb4fd7 commit 18512cd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/docker/docker.lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function docker-get-image-version-and-pull() {
188188
local versions_file="${TOOL_VERSIONS:=$(git rev-parse --show-toplevel)/.tool-versions}"
189189
local version="latest"
190190
if [[ -f "$versions_file" ]]; then
191-
line=$(grep "docker/${name} " "$versions_file" | sed "s/^#\s*//; s/\s*#.*$//" | grep "${match_version:-".*"}")
191+
line=$(grep "docker/${name} " "$versions_file" | sed "s/^#\s*//; s/\s*#.*$//" | grep "${match_version:-".*"}" || true)
192192
[ -n "$line" ] && version=$(echo "$line" | awk '{print $2}')
193193
fi
194194

0 commit comments

Comments
 (0)