wok-4.x rev 8399
linux,syslinux: no more awk in shell tools
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 05 16:34:18 2011 +0100 (2011-02-05) |
parents | af59b5551936 |
children | 7d5ccd76597b |
files | linux/stuff/bootloader.sh syslinux/stuff/tools/isohybrid.sh |
line diff
1.1 --- a/linux/stuff/bootloader.sh Sat Feb 05 04:06:47 2011 +0000 1.2 +++ b/linux/stuff/bootloader.sh Sat Feb 05 16:34:18 2011 +0100 1.3 @@ -58,10 +58,11 @@ 1.4 # usage: store16 offset data16 file 1.5 store16() 1.6 { 1.7 - echo $(( $2 + 0x10000 )) | \ 1.8 - awk '{ printf "\\\\x%02X\\\\x%02X",$1%256,($1/256)%256 }' | \ 1.9 - xargs echo -en | \ 1.10 - dd bs=2 conv=notrunc of=$3 seek=$(( $1 / 2 )) 2> /dev/null 1.11 + n=$2; i=2; while [ $i -ne 0 ]; do 1.12 + printf '\\\\x%02X' $(($n & 255)) 1.13 + i=$(($i-1)); n=$(($n >> 8)) 1.14 + done | xargs echo -en | \ 1.15 + dd bs=2 conv=notrunc of=$3 seek=$(( $1 / 2 )) 2> /dev/null 1.16 [ -n "$DEBUG" ] && printf "store16(%04X) = %04X\n" $1 $2 1>&2 1.17 } 1.18 1.19 @@ -69,9 +70,10 @@ 1.20 # usage: storelong offset data32 file 1.21 storelong() 1.22 { 1.23 - echo $2 | awk '{ printf "\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X", 1.24 - $1%256,($1/256)%256,($1/256/256)%256,($1/256/256/256)%256 }' | \ 1.25 - xargs echo -en | \ 1.26 + n=$2; i=4; while [ $i -ne 0 ]; do 1.27 + printf '\\\\x%02X' $(($n & 255)) 1.28 + i=$(($i-1)); n=$(($n >> 8)) 1.29 + done | xargs echo -en | \ 1.30 dd bs=4 conv=notrunc of=$3 seek=$(( $1 / 4 )) 2> /dev/null 1.31 [ -n "$DEBUG" ] && printf "storelong(%04X) = %08X\n" $1 $2 1>&2 1.32 }
2.1 --- a/syslinux/stuff/tools/isohybrid.sh Sat Feb 05 04:06:47 2011 +0000 2.2 +++ b/syslinux/stuff/tools/isohybrid.sh Sat Feb 05 16:34:18 2011 +0100 2.3 @@ -64,8 +64,10 @@ 2.4 # write a 32 bits data 2.5 store32() 2.6 { 2.7 - echo $2 | awk '{ for(n=$1,i=4;i--;n/=256) printf "\\\\x%02X",n%256 }' |\ 2.8 - xargs echo -en | ddq bs=1 conv=notrunc of=$iso seek=$(($1)) 2.9 + n=$2; i=4; while [ $i -ne 0 ]; do 2.10 + printf '\\\\x%02X' $(($n & 255)) 2.11 + i=$(($i-1)); n=$(($n >> 8)) 2.12 + done | xargs echo -en | ddq bs=1 conv=notrunc of=$iso seek=$(($1)) 2.13 } 2.14 2.15 main()