blob: fac6b09760565752c96bf5f1b786418bc783b774 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
format=d
while getopts xdo opt; do
case $opt in
x|d|o) format=${opt};;
?) exit 1;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 1 ] || [ ${#1} -ne 1 ]; then
printf 'usage: %s [-d|-x|-o] char\n' "$0"
printf '\t-d print number in decimal (default)\n'
printf '\t-x print number in hexadecimal\n'
printf '\t-o print number in octal\n'
exit 1
fi
printf "%${format}\n" "\"$1\""
|