Skip to content

Commit b050843

Browse files
committed
fix pipefail and || precedence in content= pipeline
content=$(grep ...; grep -v ... ||: | grep -v ...) has two issues under set -euo pipefail: (1) the first grep will exit non-zero when there are no Docker- specific entries, which will abort the script; and (2) due to ||/| precedence, the grep -v "^#" filter is not applied when the second grep -v succeeds. This can break Docker builds in repos without docker/ entries in .tool-versions.
1 parent 18512cd commit b050843

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
@@ -248,7 +248,7 @@ function _replace-image-latest-by-specific-version() {
248248

249249
if [[ -f "$versions_file" ]]; then
250250
# First, list the entries specific for Docker to take precedence, then the rest but exclude comments
251-
content=$(grep " docker/" "$versions_file"; grep -v " docker/" "$versions_file" ||: | grep -v "^#")
251+
content=$({ grep " docker/" "$versions_file" || true; grep -v " docker/" "$versions_file" || true; } | grep -v "^#" || true)
252252
echo "$content" | while IFS= read -r line; do
253253
[ -z "$line" ] && continue
254254
line=$(echo "$line" | sed "s/^#\s*//; s/\s*#.*$//" | sed "s;docker/;;")

0 commit comments

Comments
 (0)