5 # Print man pages with encoding other than us-ascii, together with
6 # their encoding by file utility and by the first line in the man page.
11 # sh print_encoding.sh man?/*
13 ######################################################################
15 # (C) Copyright 2013, Peter Schiffer <pschiffe@redhat.com>
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details
25 # (http://www.gnu.org/licenses/gpl-2.0.html).
28 if [[ $# -lt 1 ]]; then
29 echo "Usage: ${0} man?/*" 1>&2
33 printf "\n %-23s%-19s%s\n\n" "Man Page" "Encoding by file" "Encoding by first line"
36 if [[ ! -f "$f" ]]; then
40 enc
=$
(file -bi "$f" | cut
-d = -f 2)
41 if [[ $enc != "us-ascii" ]]; then
42 lenc
=$
(head -n 1 "$f" |
sed -n "s/.*coding: \([^ ]*\).*/\1/p")
43 printf " * %-23s%-19s%s\n" "$f" "$enc" "$lenc"