All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
   3 # edit-header - helper script to append/replace/remove headers with mutt
 
   5 # Based on an idea by David Champion <dgc at uchicago.edu>
 
   7 # Copyright © 2008 martin f. krafft <madduck@madduck.net>
 
   8 # Released under the terms of the Artistic Licence 2.0
 
  12 if [ ! -x "$(command -v formail)" ]; then
 
  13   echo E: formail not installed. >&2
 
  18 if [ -z "$header" ]; then
 
  19   echo "E: no header specified" >&2
 
  26   printf "Enter ${1:-header} contents: " >/dev/tty
 
  27   read contents </dev/tty
 
  31 script="${0%/*}/${2:-}"
 
  32 if [ -f "$script" ] && [ -x "$script" ]; then
 
  33   if [ -z "${__RLWRAPPED:-}" ] && [ -x $(command -v rlwrap) ]; then
 
  34     __RLWRAPPED=true exec rlwrap "$0" "$@"
 
  37   contents_source="$script"
 
  40   contents_source=get_header_contents
 
  45   *append-header|*supersede-header|*replace-header)
 
  47     [ -n "$contents" ] || contents="$(eval $contents_source $header)"
 
  49       *append-header) flag=-A;;
 
  50       *supersede-header) flag=-i;;
 
  51       *replace-header) flag=-I;;
 
  53     editor="${0%/*}/filter-proxy formail $flag \'$header: $contents\'"
 
  57     editor="${0%/*}/filter-proxy formail -I \'$header:\'"
 
  61     echo "E: unknown invocation: ${0##*/}" >&2
 
  67 echo "set my_editor=\"\$editor\""
 
  68 echo "set my_filter=\"$editor\""
 
  70 echo -n "<enter-command>set editor=\"\$my_filter\"<enter>"
 
  72 echo -n "<enter-command>set editor=\"\$my_editor\"<enter>"
 
  73 echo -n "<enter-command>unset my_filter<enter>"
 
  74 echo -n "<enter-command>unset my_editor<enter>"