From cmorgan@aracnet.com  Wed Jan 15 15:27:51 1997
Received: from trapdoor.aracnet.com (root@trapdoor.aracnet.com [204.188.47.1]) by mail.clark.net (8.7.3/8.6.5) with ESMTP id PAA28202 for <dickey@clark.net>; Wed, 15 Jan 1997 15:27:49 -0500 (EST)
Received: from shelob.aracnet.com (shelob.aracnet.com [204.188.47.2]) by trapdoor.aracnet.com (8.7.4/8.6.9) with ESMTP id MAA10954; Wed, 15 Jan 1997 12:27:45 -0800
Recieved: by shelob.aracnet.com (8.7.4)  id MAA10321; Wed, 15 Jan 1997 12:30:30 -0800
Message-Id: <199701152030.MAA10321@shelob.aracnet.com>
From: cmorgan@aracnet.com (Clark O. Morgan)
Date: Wed, 15 Jan 1997 12:30:29 -0800
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: pgf@foxharp.boston.ma.us (Paul G. Fox), dickey@clark.net
Subject: tested :-) macros for Bourne/Ksh/Bash _and_ Csh/Tcsh
Status: RO

Documentation has been expanded.
I posted this to comp.editors as well.


; Included below are 4 vile macros to sign buffers with PGP 2.6.2 plain
; text signatures.  One use for these macros is to sign e-mail messages
; or USENET postings.  When selecting one or more of the macros below, 
; choose based on these criteria:
;   - type of shell specified in $SHELL
;   - whether or not the buffer contains message headers (at top of 
;     buffer) that are separated from message body by a blank line.  
;     Some mail user agents expose headers to the end user (e.g., mush)
;     and others do not (elm).  If you post USENET messages via Pnews,
;     message headers are included in the buffer.
;
; All macros use the same principle:
;   - prompts for PGP pass phrase for user Clark (change this user id
;     as appropriate for your application)
;   - places pass phrase at appropriate point in buffer
;   - filters buffer to pgp and forces pgp to read passphrase from buffer.



; Buffer signed from the first blank line of the buffer to end-of-file.  
; Macro applicable to Bourne shell and derivatives (ksh, bash, etc).  
; Macro elides all pgp stderr output and so if something goes wrong 
; (e.g., passphrase typo), you get to figure out what happened.  Look at 
; csh-based macros below for a (slower) method that leaves error messages 
; in the buffer if pgp fails.
19 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "PGPPASSFD=0; export PGPPASSFD;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark 2>/dev/null"
    beginning-of-file
    search-forward "^[ \t]*$"
    ~force down-line
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
~endm
bind-key execute-macro-19 #-s   ; invoke with the keystroke #s

;
; Same macro as above, except that the entire buffer is signed.
;
20 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "PGPPASSFD=0; export PGPPASSFD;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark 2>/dev/null"
    beginning-of-file
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
~endm
bind-key execute-macro-20 #-S   ; invoke with the keystroke #S

; Buffer signed from the first blank line of the buffer to end-of-file.  
; Macro applicable to csh and its derivatives (tcsh, etc).  Due to 
; inherent limitations in csh commandline syntax, this macro reads all 
; pgp output (stdout & stderr) and then filters it.  Consequently, if 
; something goes wrong (e.g., passphrase typo), the pgp error msg is 
; retained in the buffer.
21 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "setenv PGPPASSFD 0;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark"
    beginning-of-file
    search-forward "^[ \t]*$"
    set-named-mark q
    ~force down-line
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
    goto-named-mark q
    down-line
    ~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-21 #-t   ; invoke with the keystroke #t

;
; Same macro as above, except that the entire buffer is signed.
;
22 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "setenv PGPPASSFD 0;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark"
    beginning-of-file
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
    beginning-of-file
    ~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-22 #-T   ; invoke with the keystroke #T

Documentation has been expanded.
I posted this to comp.editors as well.


; Included below are 4 vile macros to sign buffers with PGP 2.6.2 plain
; text signatures.  One use for these macros is to sign e-mail messages
; or USENET postings.  When selecting one or more of the macros below, 
; choose based on these criteria:
;   - type of shell specified in $SHELL
;   - whether or not the buffer contains message headers (at top of 
;     buffer) that are separated from message body by a blank line.  
;     Some mail user agents expose headers to the end user (e.g., mush)
;     and others do not (elm).  If you post USENET messages via Pnews,
;     message headers are included in the buffer.
;
; All macros use the same principle:
;   - prompts for PGP pass phrase for user Clark (change this user id
;     as appropriate for your application)
;   - places pass phrase at appropriate point in buffer
;   - filters buffer to pgp and forces pgp to read passphrase from buffer.



; Buffer signed from the first blank line of the buffer to end-of-file.  
; Macro applicable to Bourne shell and derivatives (ksh, bash, etc).  
; Macro elides all pgp stderr output and so if something goes wrong 
; (e.g., passphrase typo), you get to figure out what happened.  Look at 
; csh-based macros below for a (slower) method that leaves error messages 
; in the buffer if pgp fails.
19 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "PGPPASSFD=0; export PGPPASSFD;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark 2>/dev/null"
    beginning-of-file
    search-forward "^[ \t]*$"
    ~force down-line
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
~endm
bind-key execute-macro-19 #-s   ; invoke with the keystroke #s

;
; Same macro as above, except that the entire buffer is signed.
;
20 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "PGPPASSFD=0; export PGPPASSFD;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark 2>/dev/null"
    beginning-of-file
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
~endm
bind-key execute-macro-20 #-S   ; invoke with the keystroke #S

; Buffer signed from the first blank line of the buffer to end-of-file.  
; Macro applicable to csh and its derivatives (tcsh, etc).  Due to 
; inherent limitations in csh commandline syntax, this macro reads all 
; pgp output (stdout & stderr) and then filters it.  Consequently, if 
; something goes wrong (e.g., passphrase typo), the pgp error msg is 
; retained in the buffer.
21 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "setenv PGPPASSFD 0;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark"
    beginning-of-file
    search-forward "^[ \t]*$"
    set-named-mark q
    ~force down-line
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
    goto-named-mark q
    down-line
    ~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-21 #-t   ; invoke with the keystroke #t

;
; Same macro as above, except that the entire buffer is signed.
;
22 store-macro
    set-variable %phrase &cat @"PGP PassPhrase? " "\n"
    write-message " "  ; erase passphrase
    set-variable %var "setenv PGPPASSFD 0;"
    set-variable %cmd &cat %var "pgp -fsta -u Clark"
    beginning-of-file
    insert-string %phrase
    ~force up-line-at-bol
    filter-til end-of-file %cmd
    beginning-of-file
    ~force delete-til search-forward "--*BEGIN PGP SIGNED MESSAGE"
~endm
bind-key execute-macro-22 #-T   ; invoke with the keystroke #T

