aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-02-05 13:48:14 -0200
committerSilvio Rhatto <rhatto@riseup.net>2012-02-05 13:48:14 -0200
commit8fa3ddbc6cdf5adb3414c782ff83c371b17d38d8 (patch)
tree9da6b357ba817281300c8d771bda932b6ce54e0f /lib
parenteb9fc837e97d4be9275a6ec07ebcab1a660bbcd8 (diff)
downloadkeyringer-8fa3ddbc6cdf5adb3414c782ff83c371b17d38d8.tar.gz
keyringer-8fa3ddbc6cdf5adb3414c782ff83c371b17d38d8.tar.bz2
Fixing init command and checking for empty recipients file
Diffstat (limited to 'lib')
-rw-r--r--lib/keyringer/functions16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 58f7ad1..da8be2e 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -95,10 +95,9 @@ function keyringer_is_git {
elif [ -d "$1/.git" ]; then
true
else
- cwd="`pwd`"
- cd "$1" && git="`git status &> /dev/null`" && cd "$cwd"
+ ( cd "$1" && git status &> /dev/null )
- if [ "$git" != "128" ]; then
+ if [ "$?" != "128" ]; then
true
else
false
@@ -225,7 +224,9 @@ function keyringer_check_version {
if [ ! -f "$VERSION_INFO" ]; then
echo "Creating configuration version file..."
echo 0 > "$VERSION_INFO"
- keyringer_exec git "$BASEDIR" add config/version
+ if keyringer_is_git "$BASEDIR"; then
+ keyringer_exec git "$BASEDIR" add config/version
+ fi
fi
VERSION="`cat $VERSION_INFO`"
@@ -282,6 +283,13 @@ function keyringer_action_usage {
# Check recipients
function keyringer_check_recipients {
+ # Check if recipients file is empty.
+ if [ "`grep -vE "^#|^$" "$RECIPIENTS" | wc -l`" == 0 ] && [ "$SUBCOMMAND" != "edit" ]; then
+ echo "Fatal: no recipients configured for this keyring."
+ echo "Please edit your recipients file first."
+ exit 1
+ fi
+
# Check recipients header for updates.
if grep -qe ' XXXXXXXX$' "$RECIPIENTS"; then
echo "Updating recipients file..."