Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/bashly/templates/lib/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,26 @@ config_show() {
config_init
cat "$CONFIG_FILE"
}

# Return an array of the keys in the config file
# Usage:
#
# for k in $(config_keys); do
# echo "- $k = $(config_get "$k")";
# done
#
config_keys() {
key=$1
regex="^(.*)\s*="

config_init

keys=()
while IFS= read -r line || [ -n "$line" ]; do
if [[ $line =~ $regex ]]; then
key="${BASH_REMATCH[1]}"
keys+=("$key")
fi
done < "$CONFIG_FILE"
echo ${keys[@]}
}