Skip to content

Instantly share code, notes, and snippets.

@delphinus
Created July 24, 2012 08:43
Show Gist options
  • Select an option

  • Save delphinus/3168896 to your computer and use it in GitHub Desktop.

Select an option

Save delphinus/3168896 to your computer and use it in GitHub Desktop.
read POD in Perl code written in euc-jp
#!/bin/sh
usage_exit() {
echo "Usage: $0 [--from-code,-f FROM] [--to-code,-t TO] [--help,-h] file" 1>&2
exit 1
}
# default values
FROM=EUC-JP
TO=UTF-8
# option handling
GETOPT=`getopt -q -o f:t: -l from:,to:,help -- "$@"`; [ $? != 0 ] && usage_exit
eval set -- "$GETOPT"
while true; do
case $1 in
--from-code | -f) FROM=$2; shift 2;;
--to-code | -t) TO=$2; shift 2;;
--help | -h) usage_exit;;
--) shift; break;;
*) usage_exit;;
esac
done
# other args
FILE=$1
if [ "${FILE}x" = 'x' ]; then
usage_exit
fi
if [ ! -f $FILE ]; then
echo "file not found : $FILE"
exit 1
fi
pod2man $FILE | iconv -f$FROM -t$TO | nroff -man | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment