Add hexprint(); display the given number as hex.
Add a comment to document zeropad()'s purpose.
This commit is contained in:
parent
0534825a44
commit
117d01fe78
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh -
|
||||
# $NetBSD: MAKEDEV.tmpl,v 1.42 2005/04/30 16:26:06 augustss Exp $
|
||||
# $NetBSD: MAKEDEV.tmpl,v 1.43 2005/05/02 00:46:46 lukem Exp $
|
||||
#
|
||||
# Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
|
@ -296,7 +296,11 @@ _USAGE_
|
|||
exit 1
|
||||
}
|
||||
|
||||
zeropad() {
|
||||
# zeropad width number
|
||||
# display number with a zero (`0') padding of width digits.
|
||||
#
|
||||
zeropad()
|
||||
{
|
||||
case $(($1 - ${#2})) in
|
||||
5) echo 00000$2;;
|
||||
4) echo 0000$2;;
|
||||
|
@ -308,6 +312,23 @@ zeropad() {
|
|||
esac
|
||||
}
|
||||
|
||||
# hexprint number
|
||||
# display (base10) number as hexadecimal
|
||||
#
|
||||
hexprint()
|
||||
{
|
||||
case $1 in
|
||||
[0-9]) echo $1 ;;
|
||||
10) echo a ;;
|
||||
11) echo b ;;
|
||||
12) echo c ;;
|
||||
13) echo d ;;
|
||||
14) echo e ;;
|
||||
15) echo f ;;
|
||||
*) echo $(hexprint $(($1 / 16)))$(hexprint $(($1 % 16))) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
do_force=false
|
||||
do_specfile=false
|
||||
while getopts fm:s ch; do
|
||||
|
|
Loading…
Reference in New Issue