Browse Source

added error for empty file

panda 7 years ago
parent
commit
6fb8509eed
1 changed files with 8 additions and 1 deletions
  1. 8 1
      gnano

+ 8 - 1
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