#!/bin/sh
# Export pass store to CSV format on stdout. Version 1
# Use PASSWORD_STORE_DIR environment variable to override location.
encode() {
# If first argument is 1, then only output the first line.
# Encode double-quote character as CSV-escaped ""
# Encode newline character as C-escaped \n
awk -v onlyfirst="$1" '{
if (length(last) > 0) {
if (onlyfirst) exit
gsub(/"/, "\"\"", last)
printf "%s%cn", last, "\\"
}
last = $0
}
END {
if (length(last) > 0) {
gsub(/"/, "\"\"", last)
printf "%s", last
}
}'
return
}