commit 1c2ed54622637fe4c66131a14fe63642480e054b
parent 5e385e1c331121230fac7dc9e88bcac15bbf4a1f
Author: Klemens Nanni <kl3@posteo.org>
Date: Mon, 16 May 2016 01:17:39 +0200
Change synposis from {insert,remove,abort} to {add,del,die}
Diffstat:
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
@@ -15,11 +15,11 @@ From the original project:
Create a new entry with a random password using `pwgen`:
- $ pwgen -1 | tpm insert system/new-user
+ $ pwgen -1 | tpm add system/new-user
Create a new entry called *system/root*:
- $ tpm insert system/root
+ $ tpm add system/root
Write your *system/root* password to standard output:
diff --git a/README.pod b/README.pod
@@ -15,9 +15,9 @@ the latter is a lot more minimal. Furthermore, tpm is written entirely
in POSIX shell.
Adding, removing or showing a password is done by invoking tpm with the
-I<insert>, I<remove> or I<show> command respectively followed by a
-name. tpm will then prompt for a password or confirmation before it
-modifies or shows the corresponding entry.
+I<add>, I<del> or I<show> command respectively followed by a name.
+tpm will then prompt for a password or confirmation before it modifies
+or shows the corresponding entry.
When using the I<show> command, globbing is allowed to avoid typing
potentially long entry paths. In case multiple entries match, tpm exits
@@ -64,11 +64,11 @@ The default storage directory.
Create a new entry with a random password using pwgen(1):
- $ pwgen -1 | tpm insert system/new-user
+ $ pwgen -1 | tpm add system/new-user
Create a new entry called 'system/root':
- $ tpm insert system/root
+ $ tpm add system/root
Write your 'system/root' password to standard output:
diff --git a/tpm.sh b/tpm.sh
@@ -30,7 +30,7 @@ fi
## Helper
-abort() {
+die() {
printf '%s\n' "${1}" 1>&2
exit 1
}
@@ -47,14 +47,14 @@ readpw() {
## Commands
-insert() {
- [ -z "${1}" ] && abort 'Name must not be empty.'
- [ -e "${STORE_DIR}"/"${1}".gpg ] && abort 'Entry already exists.'
+add() {
+ [ -z "${1}" ] && die 'Name must not be empty.'
+ [ -e "${STORE_DIR}"/"${1}".gpg ] && die 'Entry already exists.'
readpw "Password for '${1}': " password
[ -t 0 ] && printf '\n'
- [ -z "${password}" ] && abort 'No password specified.'
+ [ -z "${password}" ] && die 'No password specified.'
mkdir -p "$(dirname "${STORE_DIR}"/"${1}".gpg)"
printf '%s\n' "${password}" \
@@ -65,32 +65,32 @@ list() {
[ -d "${STORE_DIR}" ] || mkdir -p "${STORE_DIR}"
[ -n "${1}" ] && [ ! -d "${STORE_DIR}/${1}" ] \
- && abort "No such group. See 'tpm list'."
+ && die "No such group. See 'tpm list'."
tree --noreport -l -C -- "${STORE_DIR}/${1}" \
| sed 's/.gpg$//g'
printf '\n'
}
-remove() {
- [ -z "${1}" ] && abort 'Name must not be empty.'
- [ -w "${STORE_DIR}"/"${1}".gpg ] || abort 'No such entry.'
+del() {
+ [ -z "${1}" ] && die 'Name must not be empty.'
+ [ -w "${STORE_DIR}"/"${1}".gpg ] || die 'No such entry.'
rm -i "${STORE_DIR}"/"${1}".gpg
}
show() {
- [ -z "${1}" ] && abort 'Name must not be empty.'
+ [ -z "${1}" ] && die 'Name must not be empty.'
entry="${STORE_DIR}"/"${1}".gpg
if [ ! -r "${entry}" ]; then
entry=$(find "${STORE_DIR}" -type f -iwholename "*${1}*".gpg)
- [ -z "${entry}" ] && abort 'No such entry.'
+ [ -z "${entry}" ] && die 'No such entry.'
[ "$(printf '%s' "${entry}" | wc -l)" -gt 0 ] \
- && abort 'Too ambigious keyword.'
+ && die 'Too ambigious keyword.'
fi
gpg2 ${GPG_OPTS} --decrypt "${entry}"
@@ -99,20 +99,20 @@ show() {
## Parse input
[ ${#} -eq 0 ] || [ ${#} -gt 2 ] \
- && abort "Invalid number of arguments. See 'tpm help'."
+ && die "Invalid number of arguments. See 'tpm help'."
case "${1}" in
- insert|list|remove|show)
- ${1} "${2}"
+ add|del|list|show)
+ ${1} "${2}"
;;
help)
cat <<- EOF
- USAGE: tpm show|insert|list|help [ENTRY|GROUP]
+ USAGE: tpm add|del|list|show|help [ENTRY|GROUP]
See tpm(1) for more information.
EOF
;;
*)
- abort "Invalid command. See 'tpm help'."
+ die "Invalid command. See 'tpm help'."
;;
esac