#!/usr/local/bin/wish -f

wm withdraw .

set tkmail [lindex $argv 0]
set mfc [lindex $argv 1]
set tfile [lindex $argv 2]
set tcmd [lrange $argv 3 end]
set tcmd [string trim $tcmd "{}"]

if {[catch "exec $tcmd" res]} {
    if {[catch "send $tkmail \"mf_mailerror {$res} $mfc\""]} {
        puts stderr $res
    }
    exit
}

if {[catch "send $tkmail \"mfv:alt-edit-finish $mfc $tfile\"" res]} {
  puts stderr $res
}

exit

