20 lines
458 B
Bash
Executable File
20 lines
458 B
Bash
Executable File
#!/bin/sh
|
|
|
|
validate_secret_file() {
|
|
secret_path=$1
|
|
secret_name=$2
|
|
if [ ! -f "$secret_path" ] || [ ! -r "$secret_path" ] || [ ! -s "$secret_path" ]; then
|
|
echo "$secret_name must be a readable, non-empty regular file" >&2
|
|
return 2
|
|
fi
|
|
if LC_ALL=C grep -q '[[:space:]]' "$secret_path"; then
|
|
echo "$secret_name must contain no whitespace" >&2
|
|
return 2
|
|
fi
|
|
}
|
|
|
|
read_secret_file() {
|
|
validate_secret_file "$1" "$2" || return
|
|
cat "$1"
|
|
}
|