@@ -51,7 +51,7 @@ function docker-build() {
5151
5252 # Tag the image with all the stated versions, see the documentation for more details
5353 for version in $( _get-all-effective-versions) latest; do
54- if [ ! -z " $version " ]; then
54+ if [[ -n " $version " ] ]; then
5555 $DOCKER_CMD tag " ${tag} " " ${DOCKER_IMAGE} :${version} "
5656 fi
5757 done
@@ -150,7 +150,7 @@ function version-create-effective-file() {
150150 local version_file=" $dir /VERSION"
151151 local build_datetime=${BUILD_DATETIME:- $(date -u +' %Y-%m-%dT%H:%M:%S%z' )}
152152
153- if [ -f " $version_file " ]; then
153+ if [[ -f " $version_file " ] ]; then
154154 # shellcheck disable=SC2002
155155 cat " $version_file " | \
156156 sed " s/\(\$ {yyyy}\|\$ yyyy\)/$( date --date=" ${build_datetime} " -u +" %Y" ) /g" | \
@@ -190,9 +190,9 @@ function docker-get-image-version-and-pull() {
190190 # match it by name and version regex, if given.
191191 local versions_file=" ${TOOL_VERSIONS:= $(git rev-parse --show-toplevel)/ .tool-versions} "
192192 local version=" latest"
193- if [ -f " $versions_file " ]; then
193+ if [[ -f " $versions_file " ] ]; then
194194 line=$( grep " docker/${name} " " $versions_file " | sed " s/^#\s*//; s/\s*#.*$//" | grep " ${match_version:- " .*" } " )
195- [ -n " $line " ] && version=$( echo " $line " | awk ' {print $2}' )
195+ [[ -n " $line " ] ] && version=$( echo " $line " | awk ' {print $2}' )
196196 fi
197197
198198 # Split the image version into two, tag name and digest sha256.
@@ -201,7 +201,7 @@ function docker-get-image-version-and-pull() {
201201
202202 # Check if the image exists locally already
203203 if ! $DOCKER_CMD images | awk ' { print $1 ":" $2 }' | grep -q " ^${name} :${tag} $" ; then
204- if [ " $digest " != " latest" ]; then
204+ if [[ " $digest " != " latest" ] ]; then
205205 # Pull image by the digest sha256 and tag it
206206 $DOCKER_CMD pull \
207207 --platform linux/amd64 \
@@ -234,7 +234,7 @@ function _create-effective-dockerfile() {
234234 # Dockerfile.effective file, otherwise docker won't use it.
235235 # See https://docs.docker.com/build/building/context/#filename-and-location
236236 # If using podman, this requires v5.0.0 or later.
237- if [ -f " ${dir} /Dockerfile.dockerignore" ]; then
237+ if [[ -f " ${dir} /Dockerfile.dockerignore" ] ]; then
238238 cp " ${dir} /Dockerfile.dockerignore" " ${dir} /Dockerfile.effective.dockerignore"
239239 fi
240240 cp " ${dir} /Dockerfile" " ${dir} /Dockerfile.effective"
@@ -252,19 +252,19 @@ function _replace-image-latest-by-specific-version() {
252252 local dockerfile=" ${dir} /Dockerfile.effective"
253253 local build_datetime=${BUILD_DATETIME:- $(date -u +' %Y-%m-%dT%H:%M:%S%z' )}
254254
255- if [ -f " $versions_file " ]; then
255+ if [[ -f " $versions_file " ] ]; then
256256 # First, list the entries specific for Docker to take precedence, then the rest but exclude comments
257257 content=$( grep " docker/" " $versions_file " ; grep -v " docker/" " $versions_file " || : | grep -v " ^#" )
258258 echo " $content " | while IFS= read -r line; do
259- [ -z " $line " ] && continue
259+ [[ -z " $line " ] ] && continue
260260 line=$( echo " $line " | sed " s/^#\s*//; s/\s*#.*$//" | sed " s;docker/;;" )
261261 name=$( echo " $line " | awk ' {print $1}' )
262262 version=$( echo " $line " | awk ' {print $2}' )
263263 sed -i " s;\(FROM .*\)${name} :latest;\1${name} :${version} ;g" " $dockerfile "
264264 done
265265 fi
266266
267- if [ -f " $dockerfile " ]; then
267+ if [[ -f " $dockerfile " ] ]; then
268268 # shellcheck disable=SC2002
269269 cat " $dockerfile " | \
270270 sed " s/\(\$ {yyyy}\|\$ yyyy\)/$( date --date=" ${build_datetime} " -u +" %Y" ) /g" | \
@@ -314,7 +314,7 @@ function _get-effective-tag() {
314314
315315 local tag=$DOCKER_IMAGE
316316 version=$( _get-effective-version)
317- if [ ! -z " $version " ]; then
317+ if [[ -n " $version " ] ]; then
318318 tag=" ${tag} :${version} "
319319 fi
320320 echo " $tag "
@@ -336,9 +336,9 @@ function _get-git-branch-name() {
336336
337337 local branch_name=$( git rev-parse --abbrev-ref HEAD)
338338
339- if [ -n " ${GITHUB_HEAD_REF:- } " ]; then
339+ if [[ -n " ${GITHUB_HEAD_REF:- } " ] ]; then
340340 branch_name=$GITHUB_HEAD_REF
341- elif [ -n " ${GITHUB_REF:- } " ]; then
341+ elif [[ -n " ${GITHUB_REF:- } " ] ]; then
342342 # shellcheck disable=SC2001
343343 branch_name=$( echo " $GITHUB_REF " | sed " s#refs/heads/##" )
344344 fi
0 commit comments