summaryrefslogtreecommitdiff
path: root/nocompile/bin/mime-type
blob: 83dc116ed384a40395683e9cb8a586dd461ed293 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
EXT="$(printf "%s" "$1" | rev | cut -d. -f1 | rev)"
TYPE="$(file -b --mime-type "$1")"
MAIN="$(printf "%s" "${TYPE}" | cut -d/ -f1)"
SUB="$(printf "%s" "${TYPE}" | cut -d/ -f2)"
if [ "_${MAIN}" = "_inode" ];then
 TYPE="text/plain" 
fi
if [ "_${MAIN}" = "_text" -a "_${SUB}" != "_html" ];then
 TYPE="text/plain"
fi
if [ "_${EXT}" = "_css" ];then
 TYPE="text/css"
fi
printf "%s\r\n" "$TYPE"