This commit is contained in:
commit
9b5294bb7e
6 changed files with 325 additions and 0 deletions
19
scripts/ensure_no_spaces.sh
Normal file
19
scripts/ensure_no_spaces.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
# Ensure no spaces are in the input environment variable(s)
|
||||
# specify the environment variable(s) to validate as an argument (or array of arguments)
|
||||
# reserve first argument for the environment variable name
|
||||
|
||||
ENV_VAR_NAME=$1
|
||||
|
||||
for var in "${@:2}"; do
|
||||
# get the value of the specified environment variable
|
||||
value=$(eval echo \$$var)
|
||||
# check if the value has spaces
|
||||
if [[ $value =~ [[:space:]] ]]; then
|
||||
echo "❌ Invalid $ENV_VAR_NAME: $value"
|
||||
echo "ℹ️ $ENV_VAR_NAME must not have spaces"
|
||||
exit 1
|
||||
else
|
||||
echo "✅ $ENV_VAR_NAME is valid: $value"
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue