lirc.4: srcfix: add missing .TH line
[man-pages.git] / scripts / print_encoding.sh
blobd6afc3e916e5218e11386712ec2abd9cb40224d5
1 #!/bin/sh
3 # print_encoding.sh
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.
8 # Example usage:
10 # cd man-pages-x.yy
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
30 exit 1
33 printf "\n %-23s%-19s%s\n\n" "Man Page" "Encoding by file" "Encoding by first line"
35 for f in "$@"; do
36 if [[ ! -f "$f" ]]; then
37 continue
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"
45 done
47 exit 0