Align shell style all over the repo

This commit is contained in:
Lucas 2020-05-03 14:47:27 +00:00
parent afb13d9c9c
commit d5e71c46f7
16 changed files with 113 additions and 86 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
# sekrit
# Written in 2018-2019 by Lucas
# Written in 2018-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@ -50,7 +50,7 @@ check_key()
{
case $1 in
*/ | /* | ./* | */./* | */. | ../* | */../* | */..)
err "Key can not end in a slash."
err "$1: invalid key"
;;
esac
}
@ -70,9 +70,10 @@ sekrit_add()
f=$SEKRIT_DIR/$key.gpg
mkdir -p "${f%/*}"
[ -f "$f" ] && err "Key \"$key\" already exists."
[ -f "$f" ] && err "key $key already exists"
if [ $# -gt 0 ]; then
# use all additional parameters as a single string
printf "%s\n" "$*"
else
cat -
@ -88,13 +89,13 @@ sekrit_gen()
while getopts l: flag; do
case "$flag" in
l) len=$(to_number "$OPTARG") ||
err "Invalid password length."
err "invalid password length"
;;
*) usage
;;
esac
done
shift $(($OPTIND - 1))
shift $((OPTIND - 1))
[ $# -le 1 ] || usage
@ -116,7 +117,7 @@ sekrit_get()
shift
f=$SEKRIT_DIR/$key.gpg
[ -f "$f" ] || err "No data for key \"$key\"."
[ -f "$f" ] || err "no data for key $key"
gpg2 -qd "$f"
}