From 6fb8509eedd366381b4a8fb9cdaa18211066f878 Mon Sep 17 00:00:00 2001 From: panda Date: Tue, 7 Mar 2017 10:44:49 +0100 Subject: [PATCH] added error for empty file --- gnano | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gnano b/gnano index 15bba34..3435072 100755 --- a/gnano +++ b/gnano @@ -3,6 +3,11 @@ #GNANO - gpg-enabled nano #gnano enables you to edit a textfile encrypted for some recipients without outputting to cleartext the content (actually it outputs it in a tempfile which permissions are 600, I am working on yhis issue) +if [[ -z $1 ]]; then + echo "FILE NOT SPECIFIED, EXITING!" + exit 1 +fi + #check program prerequisites: hash vipe 2>/dev/null || { echo >&2 "I require vipe but it's not installed. It's part of the package morutils, under debian-like systems: 'apt-get install moreutils' Aborting."; exit 1; } hash gpg 2>/dev/null || { echo >&2 "I require gpg but it's not installed. Aborting."; exit 1; } @@ -64,6 +69,8 @@ if [[ $new -eq "0" ]]; then exit 1 fi + cp $argument $argument"_BCK" + gpg --batch --list-only --no-default-keyring --secret-keyring /dev/null $argument &> $tempfile cat $tempfile | grep "gpg: encrypted" | awk '{print $8}' | sed 's/\,//g' > $tempfile sleep 0.5 @@ -81,7 +88,7 @@ if [[ $new -eq "0" ]]; then fi -#LOOP OFR NEW FILE: +#LOOP FOR NEW FILE: if [[ $new -eq "1" ]]; then for newrcpt in $(echo $newrecipients | tr "," "\n") do