--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhsign (correct alias expansion with -enc)
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# setup some aliases
+
+cat >"$MH_TEST_DIR/.mmh/aliases" <<!
+a1: unknownperson
+a2: unknownperson@example.org
+a3: Unknown Person <unknownperson>
+a4: Unknown Person <unknownperson@example.org>
+a5: "Unknown Person" <unknownperson@example.org>
+a6: (Unknown) <unknownperson@example.org> (Person)
+a7: Unknown <unknownperson@example.org>, unknownperson@example.org
+!
+cat >>"$MH_TEST_DIR/.mmh/profile" <<!
+aliasfile: aliases
+!
+
+
+# override gpg with our own function for defined output
+
+echo '#!/bin/sh
+exit 1
+' >"$MH_TEST_DIR/bin/gpg"
+chmod +x "$MH_TEST_DIR/bin/gpg"
+export MMHPGPKEY=0x12345678
+
+
+# now test it
+
+draft=`mhpath +drafts b`
+cat >"$draft" <<!
+To: a1, a2, a3, a4, a5
+Cc: a6, a7
+Subject: mhsign -enc test
+--------
+secret
+!
+
+runandcheck "whom -noali $draft" <<!
+a1
+a2
+a3
+a4
+a5
+a6
+a7
+!
+
+runandcheck "whom -ali $draft" <<!
+unknownperson
+unknownperson@example.org
+Unknown Person <unknownperson>
+Unknown Person <unknownperson@example.org>
+"Unknown Person" <unknownperson@example.org>
+(Unknown) <unknownperson@example.org> (Person)
+Unknown <unknownperson@example.org>
+unknownperson@example.org
+!
+
+runandcheck "mhsign -enc $draft" <<!
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+!
echo "Encryption is not supported for BCCs" >&2
return 1
fi
-
- for i in `whom -ali -tocc -nobcc "$1"` ; do
+
+ whom -ali -tocc -nobcc "$1" | while read i ; do
case "$i" in
'|'*) echo "Ignoring pipe address" >&2
continue ;;
*@*) ;;
- *) i="$i@`hostname -f`" ;;
+ *) a="$i@`hostname -f`" ;;
esac
+ # extract the actual address
+ format='%<{error}%{error}: %{text}%|%(addr{text})%>'
+ i=`%libdir%/ap -form "=$format" "$i"`
if k=`lookupkeyfile "$i"` ; then
KL="$KL $k"
elif k=`lookupkeyring "$i"` ; then