diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2014-02-16 08:17:08 +0100 |
---|---|---|
committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2014-02-16 08:32:08 +0100 |
commit | 7a9cda971e5d35cbf6d6d5b9305d2e1bc4a9b84e (patch) | |
tree | 2d97844daccd1fdc2766c6e4468f65ad66f84215 /scripts | |
parent | 2bde1fa364b91f23625df7fc1519f30b2cdc5a81 (diff) | |
download | man-pages-7a9cda971e5d35cbf6d6d5b9305d2e1bc4a9b84e.tar.gz |
print_encoding.sh: Script to list pages that employ character sets other than us-ascii
See https://bugzilla.kernel.org/show_bug.cgi?id=60807
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/print_encoding.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/print_encoding.sh b/scripts/print_encoding.sh new file mode 100644 index 0000000000..d6afc3e916 --- /dev/null +++ b/scripts/print_encoding.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# print_encoding.sh +# +# Print man pages with encoding other than us-ascii, together with +# their encoding by file utility and by the first line in the man page. +# +# Example usage: +# +# cd man-pages-x.yy +# sh print_encoding.sh man?/* +# +###################################################################### +# +# (C) Copyright 2013, Peter Schiffer <pschiffe@redhat.com> +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if [[ $# -lt 1 ]]; then + echo "Usage: ${0} man?/*" 1>&2 + exit 1 +fi + +printf "\n %-23s%-19s%s\n\n" "Man Page" "Encoding by file" "Encoding by first line" + +for f in "$@"; do + if [[ ! -f "$f" ]]; then + continue + fi + + enc=$(file -bi "$f" | cut -d = -f 2) + if [[ $enc != "us-ascii" ]]; then + lenc=$(head -n 1 "$f" | sed -n "s/.*coding: \([^ ]*\).*/\1/p") + printf " * %-23s%-19s%s\n" "$f" "$enc" "$lenc" + fi +done + +exit 0 |