1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-10 09:50:58 +02:00
opentelemetry-go/get_main_pkgs.sh
ET 6b632815f8 Use /usr/bin/env bash rather than /bin/bash (#336)
get_main_pkgs.sh uses 'mapfile' which is not available in Bash
versions earlier than 4.x. On machines where the default installed
bash is 3.x (OSX), this causes `make precommit` to break.

However, it's easy enough to install a recent version of
bash (e.g. via homebrew) in `/usr/local/bin/bash`. With
`/usr/local/bin` in your path, and `/usr/bin/env bash` as the shebang
line, this enables `make precommit` to pass with flying colors.
2019-11-21 16:19:11 -08:00

23 lines
500 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
top_dir='.'
if [[ $# -gt 0 ]]; then
top_dir="${1}"
fi
p=$(pwd)
mod_dirs=()
mapfile -t mod_dirs < <(find "${top_dir}" -type f -name 'go.mod' -exec dirname {} \; | sort)
for mod_dir in "${mod_dirs[@]}"; do
cd "${mod_dir}"
main_dirs=()
mapfile -t main_dirs < <(go list --find -f '{{.Name}}|{{.Dir}}' ./... | grep '^main|' | cut -f 2- -d '|')
for main_dir in "${main_dirs[@]}"; do
echo ".${main_dir#${p}}"
done
cd "${p}"
done