From 1e0ae2a4e3c0bab562d7f8c8ee9539a0613357b6 Mon Sep 17 00:00:00 2001 From: User Erdgeist Date: Mon, 10 Feb 2014 01:12:15 +0000 Subject: Avoid bashisms in arithmetic expansion --- src/makecolumns.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/makecolumns.sh b/src/makecolumns.sh index 1d3fcd1..ab61c29 100755 --- a/src/makecolumns.sh +++ b/src/makecolumns.sh @@ -50,12 +50,12 @@ do_decompress_old() { printf "done.\n" printf "Decompressing $2 chunks ... " - number_of_files=`find . -name \*.lha | wc -l` + numfiles=`find . -name \*.lha | wc -l` reported=0; processed=0 for archive in *.lha; do lha x ${archive} > /dev/null rm ${archive} - [ 1 -eq $(( ( processed++ * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) + [ 1 -eq $(( ( (processed+=1) * 20 ) / numfiles > reported )) ] && printf "%d%% " $(( (reported+=1) * 5 )) done [ $reported -lt 10 ] && printf "100% " printf "done.\n" @@ -144,7 +144,7 @@ handle_old_format() { vname_file=`printf "%s + 3\n" ${vname_file} | bc` vname_file=`printf %0${filename_len}d ${vname_file}` table_file=`printf "%s + 3\n" ${table_file} | bc` - [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) + [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( (reported+=1) * 5 )) table_file=`printf %0${filename_len}d ${table_file}` done printf "done.\n" @@ -206,11 +206,11 @@ handle_new_format() { # Do enumerations with builtin shell tools. Unfortunally neither # jot nor seq are standards printf "Splitting decompressed chunks into their columns (11 total) ... 1, " - f=0; while [ $f -lt $rows ]; do printf "file_%05X " $(( f++ * 11)); done | xargs cat | xxd -ps -c1 > column_0 + f=-1; while [ $f -lt $rows ]; do printf "file_%05X " $(( (f+=1) * 11)); done | xargs cat | xxd -ps -c1 > column_0 - for column in 1 2 3 4 5 6 7 8 9 10; do - printf "%d, " $(( column + 1 )) - f=0; while [ $f -lt $rows ]; do printf "file_%05X " $(( column + f++ * 11 )); done | xargs cat | tr '\n\0' '\t\n' > column_${column} + for col in 1 2 3 4 5 6 7 8 9 10; do + printf "%d, " $(( col + 1 )) + f=-1; while [ $f -lt $rows ]; do printf "file_%05X " $(( col + (f+=1) * 11 )); done | xargs cat | tr '\n\0' '\t\n' > column_${col} done printf "done.\n" -- cgit v1.2.3