Skip to content

Instantly share code, notes, and snippets.

@DonBattery
Last active November 3, 2018 20:36
Show Gist options
  • Save DonBattery/70003ad51b4cdc94d842bbd2572c89bc to your computer and use it in GitHub Desktop.
Save DonBattery/70003ad51b4cdc94d842bbd2572c89bc to your computer and use it in GitHub Desktop.
set the FILEKVS_DIRECTORY env, and source this file to get a file-based key:value store
# donbattery's poopdb
if [ ! -d "$FILEKVS_DIRECTORY" ]; then
printf "cannot find poopdb at %s\n" "$FILEKVS_DIRECTORY"
return
fi
filekvs_get () {
[ -f "$FILEKVS_DIRECTORY/$1" ] && printf "%s" "$(< "$FILEKVS_DIRECTORY/$1")"
}
filekvs_set () {
printf "%s" "$2" > "$FILEKVS_DIRECTORY/$1"
}
filekvs_del () {
[ -f "$FILEKVS_DIRECTORY/$1" ] && rm "$FILEKVS_DIRECTORY/$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment