added error for empty file
This commit is contained in:
parent
51592ad78b
commit
6fb8509eed
1 changed files with 8 additions and 1 deletions
9
gnano
9
gnano
|
@ -3,6 +3,11 @@
|
||||||
#GNANO - gpg-enabled nano
|
#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)
|
#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:
|
#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 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; }
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cp $argument $argument"_BCK"
|
||||||
|
|
||||||
gpg --batch --list-only --no-default-keyring --secret-keyring /dev/null $argument &> $tempfile
|
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
|
cat $tempfile | grep "gpg: encrypted" | awk '{print $8}' | sed 's/\,//g' > $tempfile
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
@ -81,7 +88,7 @@ if [[ $new -eq "0" ]]; then
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#LOOP OFR NEW FILE:
|
#LOOP FOR NEW FILE:
|
||||||
if [[ $new -eq "1" ]]; then
|
if [[ $new -eq "1" ]]; then
|
||||||
for newrcpt in $(echo $newrecipients | tr "," "\n")
|
for newrcpt in $(echo $newrecipients | tr "," "\n")
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in a new issue