bin/update-go-deps-shas: Fix shellcheck issues (#4435)

Pass grep output through xargs.
Use `${0%/*}` instead of `$bindir `since the variable `bindir` exists in
_tag.sh too and then triggers the shellcheck variable modifed warning.
Script uses no bash features and can thus be a POSIX /bin/sh script.

Signed-off-by: Joakim Roubert <joakimr@axis.com>
This commit is contained in:
Joakim Roubert 2020-05-19 22:00:34 +02:00 committed by GitHub
parent 5f37a9f7fa
commit b2082712b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -87,7 +87,6 @@ jobs:
! -name _tag.sh \
! -name test-cleanup \
! -name _test-run.sh \
! -name update-go-deps-shas \
! -name *.nuspec \
! -name *.ps1 \
| xargs -I {} bin/shellcheck -x -P ./bin {}

View File

@ -1,15 +1,13 @@
#!/bin/bash
#!/bin/sh
set -eu
# Updates the tag for `linkerd-io/go-deps` across all Dockerfiles in this repository.
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
# shellcheck source=_tag.sh
sha=$(. "$bindir"/_tag.sh ; go_deps_sha)
sha=$(. "${0%/*}"/_tag.sh ; go_deps_sha)
for f in $( grep -lR --include=Dockerfile\* go-deps: $bindir/.. ) ; do
for f in $( grep -lR --include=Dockerfile\* go-deps: "$(cd "${0%/*}"/.. && pwd)" | xargs ) ; do
sed -E -i.bak -e "s|linkerd-io/go-deps:[^ ]+|linkerd-io/go-deps:$sha|" "$f"
rm "$f".bak
done