File: malternative

package info (click to toggle)
mblaze 1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 792 kB
  • sloc: ansic: 8,391; sh: 1,870; ruby: 128; awk: 22; makefile: 17
file content (16 lines) | stat: -rwxr-xr-x 356 bytes parent folder | download
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
	}'