]> git.ipfire.org Git - thirdparty/man-pages.git/blob - scripts/print_encoding.sh
Start of man-pages-5.02: updating .Announce and .lsm files
[thirdparty/man-pages.git] / scripts / print_encoding.sh
1 #!/bin/sh
2 #
3 # print_encoding.sh
4 #
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.
7 #
8 # Example usage:
9 #
10 # cd man-pages-x.yy
11 # sh print_encoding.sh man?/*
12 #
13 ######################################################################
14 #
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.
20 #
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).
26 #
27
28 if [[ $# -lt 1 ]]; then
29 echo "Usage: ${0} man?/*" 1>&2
30 exit 1
31 fi
32
33 printf "\n %-23s%-19s%s\n\n" "Man Page" "Encoding by file" "Encoding by first line"
34
35 for f in "$@"; do
36 if [[ ! -f "$f" ]]; then
37 continue
38 fi
39
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"
44 fi
45 done
46
47 exit 0