]> gitweb.fluxo.info Git - firma.git/commitdiff
alteracao das funcoes anteriormente modificadas
authorrhatto <rhatto>
Sun, 7 Aug 2005 15:24:07 +0000 (15:24 +0000)
committerrhatto <rhatto>
Sun, 7 Aug 2005 15:24:07 +0000 (15:24 +0000)
firma

diff --git a/firma b/firma
index e7582c1fcabedaa614f583b28c70b4c1b070287d..e81b6f39036064bc45381f2d229238c1ac48b9d1 100755 (executable)
--- 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