#!/usr/bin/env bash # vim:ts=4:sts=4:sw=4:et # # Author: Hari Sekhon # Date: 2022-06-13 11:15:06 +0100 (Mon, 13 Jun 2022) # # https://github.com/HariSekhon/DevOps-Bash-tools # # License: see accompanying Hari Sekhon LICENSE file # # If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish # # https://www.linkedin.com/in/HariSekhon # set -euo pipefail [ -n "${DEBUG:-}" ] && set -x srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck disable=SC1090 . "$srcdir/lib/utils.sh" # shellcheck disable=SC2034,SC2154 usage_description=" Git Grep's tokens that look like environment variables (UPPER_UPPER) out of the current code base underneath the given dir or \$PWD Useful to find out environment variables supported in a code base when they're not well documented Won't find short one-piece environment variables like DEBUG because otherwise we'd also return HTTPS and all sorts of other irrelevant tokens and noise. Originally written to document ArgoCD's environment variables for better administration https://github.com/argoproj/argo-cd/pull/8680 Files or extensions to exclude can optionally be specified as args, and must be valid ERE regex that match the file path suffix, filenames and file extention literals will usually be fine Examples: You may want to exclude other files like Dockerfiles, Makefiles to just focus on environment variables supported in the actual code. You can mix and match any of the following argument examples. Exclude Dockerfiles and Makefiles: ${0##*/} Dockerfile Makefile To exclude all Dockerfiles like Dockerfile and Dockerfile.dev, Dockerfile.prod etc. this ERE regex must be quoted to not expand in the shell before being passed to this script: ${0##*/} 'Dockerfile[[:alnum:].-]*' To exclude all GitHub Actions workflows: ${0##*/} '.github/workflows/[[:alnum:].-]+' " # used by usage() in lib/utils.sh # shellcheck disable=SC2034 usage_args="[