diff --git a/.travis.yml b/.travis.yml index 3a165be78..b09193884 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ jobs: env: - TEST: shfmt check script: - - docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -i 2 -l -w -ci . + - docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -sr -i 2 -l -w -ci . - git diff --color - git diff --stat=220 --color --exit-code diff --git a/functions.sh b/functions.sh index 437110b3e..70f78a6ca 100755 --- a/functions.sh +++ b/functions.sh @@ -62,7 +62,7 @@ function get_variants() { arch=$(get_arch) variantsfilter=("$@") - IFS=' ' read -ra availablevariants <<<"$(grep "^${arch}" "${dir}/architectures" | sed -E 's/'"${arch}"'[[:space:]]*//' | sed -E 's/,/ /g')" + IFS=' ' read -ra availablevariants <<< "$(grep "^${arch}" "${dir}/architectures" | sed -E 's/'"${arch}"'[[:space:]]*//' | sed -E 's/,/ /g')" if [ ${#variantsfilter[@]} -gt 0 ]; then for variant1 in "${availablevariants[@]}"; do @@ -100,16 +100,16 @@ function get_supported_arches() { shift # Get default supported arches - lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1) + lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2> /dev/null | cut -d' ' -f1) # Get version specific supported architectures if there is specialized information if [ -a "${version}"/architectures ]; then - lines=$(grep "${variant}" "${version}"/architectures 2>/dev/null | cut -d' ' -f1) + lines=$(grep "${variant}" "${version}"/architectures 2> /dev/null | cut -d' ' -f1) fi while IFS='' read -r line; do arches+=("${line}") - done <<<"${lines}" + done <<< "${lines}" echo "${arches[@]}" } @@ -149,13 +149,13 @@ function get_versions() { local default_variant default_variant=$(get_config "./" "default_variant") if [ ${#dirs[@]} -eq 0 ]; then - IFS=' ' read -ra dirs <<<"$(echo "${prefix%/}/"*/)" + IFS=' ' read -ra dirs <<< "$(echo "${prefix%/}/"*/)" fi for dir in "${dirs[@]}"; do if [ -a "${dir}/config" ]; then local subdirs - IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")" + IFS=' ' read -ra subdirs <<< "$(get_versions "${dir#./}")" for subdir in "${subdirs[@]}"; do versions+=("${subdir}") done @@ -174,7 +174,7 @@ function get_fork_name() { version=$1 shift - IFS='/' read -ra versionparts <<<"${version}" + IFS='/' read -ra versionparts <<< "${version}" if [ ${#versionparts[@]} -gt 1 ]; then echo "${versionparts[0]}" fi @@ -260,7 +260,7 @@ function get_tag() { fi local tagparts - IFS=' ' read -ra tagparts <<<"$(get_fork_name "${version}") ${tagversion}" + IFS=' ' read -ra tagparts <<< "$(get_fork_name "${version}") ${tagversion}" IFS='-' echo "${tagparts[*]}" unset IFS @@ -278,11 +278,11 @@ function sort_versions() { while IFS='' read -r line; do sorted+=("${line}") - done <<<"$(echo "${lines}" | grep "^[0-9]" | sort -r)" + done <<< "$(echo "${lines}" | grep "^[0-9]" | sort -r)" while IFS='' read -r line; do sorted+=("${line}") - done <<<"$(echo "${lines}" | grep -v "^[0-9]" | sort -r)" + done <<< "$(echo "${lines}" | grep -v "^[0-9]" | sort -r)" echo "${sorted[@]}" } @@ -312,7 +312,7 @@ function images_updated() { commit_range="$(commit_range "$@")" - IFS=' ' read -ra versions <<<"$( + IFS=' ' read -ra versions <<< "$( IFS=',' get_versions )" diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 10db8daa9..b40d7374f 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -3,7 +3,7 @@ set -e . functions.sh -hash git 2>/dev/null || { echo >&2 "git not found, exiting."; } +hash git 2> /dev/null || { echo >&2 "git not found, exiting."; } # Used dynamically: print "$array_" $1 # shellcheck disable=SC2034 @@ -23,8 +23,8 @@ cd "$(cd "${0%/*}" && pwd -P)" self="$(basename "${BASH_SOURCE[0]}")" -IFS=' ' read -ra versions <<<"$(get_versions)" -IFS=' ' read -ra versions <<<"$(sort_versions "${versions[@]}")" +IFS=' ' read -ra versions <<< "$(get_versions)" +IFS=' ' read -ra versions <<< "$(sort_versions "${versions[@]}")" url='https://github.com/nodejs/docker-node' # get the most recent commit which modified any of "$@" @@ -50,7 +50,7 @@ join() { get_stub() { local version="${1}" shift - IFS='/' read -ra versionparts <<<"${version}" + IFS='/' read -ra versionparts <<< "${version}" local stub eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')" echo "${stub}" @@ -65,11 +65,11 @@ for version in "${versions[@]}"; do fullVersion="$(get_tag "${version}" full)" majorMinorVersion="$(get_tag "${version}" majorminor)" - IFS=' ' read -ra versionAliases <<<"$fullVersion $majorMinorVersion $stub" + IFS=' ' read -ra versionAliases <<< "$fullVersion $majorMinorVersion $stub" if [ -f "${version}/Dockerfile" ]; then # Get supported architectures for a specific version. See details in function.sh - IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "default")" + IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "${version}" "default")" echo "Tags: $(join ', ' "${versionAliases[@]}")" echo "Architectures: $(join ', ' "${supportedArches[@]}")" @@ -80,7 +80,7 @@ for version in "${versions[@]}"; do # Get supported variants according to the target architecture. # See details in function.sh - IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")")" + IFS=' ' read -ra variants <<< "$(get_variants "$(dirname "${version}")")" for variant in "${variants[@]}"; do # Skip non-docker directories [ -f "${version}/${variant}/Dockerfile" ] || continue @@ -96,7 +96,7 @@ for version in "${versions[@]}"; do # Get supported architectures for a specific version and variant. # See details in function.sh - IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "${variant}")" + IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "${version}" "${variant}")" echo "Tags: $(join ', ' "${variantAliases[@]}")" echo "Architectures: $(join ', ' "${supportedArches[@]}")" diff --git a/generate-stackbrew-pr.sh b/generate-stackbrew-pr.sh index 894ae8121..4f6aebab7 100755 --- a/generate-stackbrew-pr.sh +++ b/generate-stackbrew-pr.sh @@ -96,19 +96,19 @@ if images_updated "${COMMIT_ID}"; then setup_git_author info "Cloning..." - git clone --depth 50 "https://github.com/${UPSTREAM_SLUG}.git" ${gitpath} 2>/dev/null + git clone --depth 50 "https://github.com/${UPSTREAM_SLUG}.git" ${gitpath} 2> /dev/null stackbrew="$(./generate-stackbrew-library.sh)" cd ${gitpath} - echo "${stackbrew}" >"${IMAGES_FILE}" + echo "${stackbrew}" > "${IMAGES_FILE}" git checkout -b "${BRANCH_NAME}" git add "${IMAGES_FILE}" git commit -m "$(message)" info "Pushing..." - git push "https://${GITHUB_API_TOKEN}:x-oauth-basic@github.com/${ORIGIN_SLUG}.git" -f "${BRANCH_NAME}" 2>/dev/null || fatal "Error pushing the updated stackbrew" + git push "https://${GITHUB_API_TOKEN}:x-oauth-basic@github.com/${ORIGIN_SLUG}.git" -f "${BRANCH_NAME}" 2> /dev/null || fatal "Error pushing the updated stackbrew" cd - && rm -rf ${gitpath} diff --git a/test-build.sh b/test-build.sh index 26621a1e1..7b30e7509 100755 --- a/test-build.sh +++ b/test-build.sh @@ -9,8 +9,8 @@ set -euo pipefail # Convert comma delimited cli arguments to arrays # E.g. ./test-build.sh 8,10 slim,onbuild # "8,10" becomes "8 10" and "slim,onbuild" becomes "slim onbuild" -IFS=',' read -ra versions_arg <<<"${1:-}" -IFS=',' read -ra variant_arg <<<"${2:-}" +IFS=',' read -ra versions_arg <<< "${1:-}" +IFS=',' read -ra variant_arg <<< "${2:-}" default_variant=$(get_config "./" "default_variant") @@ -62,7 +62,7 @@ function test_image() { cd "$(cd "${0%/*}" && pwd -P)" || exit -IFS=' ' read -ra versions <<<"$(get_versions . "${versions_arg[@]}")" +IFS=' ' read -ra versions <<< "$(get_versions . "${versions_arg[@]}")" if [ ${#versions[@]} -eq 0 ]; then fatal "No valid versions found!" fi @@ -82,7 +82,7 @@ for version in "${versions[@]}"; do # Get supported variants according to the target architecture. # See details in function.sh - IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")" + IFS=' ' read -ra variants <<< "$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")" for variant in "${variants[@]}"; do # Skip non-docker directories diff --git a/travis.yml.template b/travis.yml.template index 32da12913..fb258ddde 100644 --- a/travis.yml.template +++ b/travis.yml.template @@ -54,7 +54,7 @@ jobs: env: - TEST: shfmt check script: - - docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -i 2 -l -w -ci . + - docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -sr -i 2 -l -w -ci . - git diff --color - git diff --stat=220 --color --exit-code diff --git a/update.sh b/update.sh index 6466f9c20..cbab2a5ae 100755 --- a/update.sh +++ b/update.sh @@ -2,7 +2,7 @@ set -ue function usage() { - cat <>.travis.yml + - VARIANT: "'"${variant}"'"' >> .travis.yml } echo '#### DO NOT MODIFY. THIS FILE IS AUTOGENERATED #### -' | cat - travis.yml.template >.travis.yml +' | cat - travis.yml.template > .travis.yml for version in "${versions[@]}"; do parentpath=$(dirname "${version}") @@ -199,7 +199,7 @@ for version in "${versions[@]}"; do # Get supported variants according the target architecture # See details in function.sh - IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")" + IFS=' ' read -ra variants <<< "$(get_variants "${parentpath}")" if [ -f "${version}/Dockerfile" ]; then add_stage "${baseuri}" "${version}" "default"