about summary refs log tree commit diff
path: root/contrib/malternative
blob: 33fe0287da710ce3ebe81c8f30582dd169d28b9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# malternative - multipart/alternative decoding policy

{
	echo "Content-Type: $PIPE_CONTENTTYPE"
	echo
	cat
} | mshow -t - | awk '
	BEGIN { split("", ct) }
	/^    [0-9]/ { ct[++n] = $2 }
	function prefer(t) { for (i in ct) if (ct[i] == t) exit(64+i) }
	END {
		prefer("text/plain")
		prefer("text/html")
		exit 64+1  # default to first part
	}'