aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfirma39
1 files changed, 20 insertions, 19 deletions
diff --git a/firma b/firma
index e7582c1..e81b6f3 100755
--- a/firma
+++ b/firma
@@ -91,30 +91,31 @@ function get_subscribers_list {
}
function get_message {
- n=0
+ LINES=0
while read STDIN; do
- MESSAGE[$n]="$STDIN\n"
- ((++n))
+ MESSAGE[$LINES]="$STDIN\n"
+ ((++LINES))
done
- echo $n
}
function get_gpg_message {
signal=0
- x=0; n=$1
- for ((count=0;count<=n;count++)); do
- if [[ $signal == "0" ]] && [[ "$(echo "${MESSAGE[$count]}" | grep -v -e "-----BEGIN PGP MESSAGE-----")" == "" ]]; then
- GPG_MESSAGE[$x]=${MESSAGE[$count]}
- ((++x))
- signal=1
- elif [[ $signal == "1" ]]; then
- GPG_MESSAGE[$x]=${MESSAGE[$count]}
- ((++x))
- if [[ "$(echo "${MESSAGE[$count]}" | grep -v -e "-----END PGP MESSAGE-----")" == "" ]]; then
- signal=0
+ if [ ! -z "$LINES" ]; then
+ x=0; n=$LINES
+ for ((count=0;count<=n;count++)); do
+ if [[ $signal == "0" ]] && [[ "$(echo "${MESSAGE[$count]}" | grep -v -e "-----BEGIN PGP MESSAGE-----")" == "" ]]; then
+ GPG_MESSAGE[$x]=${MESSAGE[$count]}
+ ((++x))
+ signal=1
+ elif [[ $signal == "1" ]]; then
+ GPG_MESSAGE[$x]=${MESSAGE[$count]}
+ ((++x))
+ if [[ "$(echo "${MESSAGE[$count]}" | grep -v -e "-----END PGP MESSAGE-----")" == "" ]]; then
+ signal=0
+ fi
fi
- fi
- done
+ done
+ fi
}
function get_message_headers {
@@ -184,9 +185,9 @@ $DATE
function process_message {
# process a message sent to the list
- lines=`get_message`
+ get_message
get_message_headers
- get_gpg_message $lines
+ get_gpg_message
# if signature is Good, encrypt and send it for each list subscriber
# todo: declare a function to decrypt, re-encrypt and send the list messages