diff options
author | User Erdgeist <erdgeist@avon.ccc.de> | 2014-02-10 01:12:15 +0000 |
---|---|---|
committer | User Erdgeist <erdgeist@avon.ccc.de> | 2014-02-10 01:12:15 +0000 |
commit | 1e0ae2a4e3c0bab562d7f8c8ee9539a0613357b6 (patch) | |
tree | 24b248e05e1f7a8b34cb3416941bb29c2bd8c499 /src | |
parent | b8257a00a53e08f63c095f2907d8d37180e0d5f8 (diff) |
Avoid bashisms in arithmetic expansion
Diffstat (limited to 'src')
-rwxr-xr-x | src/makecolumns.sh | 14 |
1 files changed, 7 insertions, 7 deletions
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() { | |||
50 | printf "done.\n" | 50 | printf "done.\n" |
51 | 51 | ||
52 | printf "Decompressing $2 chunks ... " | 52 | printf "Decompressing $2 chunks ... " |
53 | number_of_files=`find . -name \*.lha | wc -l` | 53 | numfiles=`find . -name \*.lha | wc -l` |
54 | reported=0; processed=0 | 54 | reported=0; processed=0 |
55 | for archive in *.lha; do | 55 | for archive in *.lha; do |
56 | lha x ${archive} > /dev/null | 56 | lha x ${archive} > /dev/null |
57 | rm ${archive} | 57 | rm ${archive} |
58 | [ 1 -eq $(( ( processed++ * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) | 58 | [ 1 -eq $(( ( (processed+=1) * 20 ) / numfiles > reported )) ] && printf "%d%% " $(( (reported+=1) * 5 )) |
59 | done | 59 | done |
60 | [ $reported -lt 10 ] && printf "100% " | 60 | [ $reported -lt 10 ] && printf "100% " |
61 | printf "done.\n" | 61 | printf "done.\n" |
@@ -144,7 +144,7 @@ handle_old_format() { | |||
144 | vname_file=`printf "%s + 3\n" ${vname_file} | bc` | 144 | vname_file=`printf "%s + 3\n" ${vname_file} | bc` |
145 | vname_file=`printf %0${filename_len}d ${vname_file}` | 145 | vname_file=`printf %0${filename_len}d ${vname_file}` |
146 | table_file=`printf "%s + 3\n" ${table_file} | bc` | 146 | table_file=`printf "%s + 3\n" ${table_file} | bc` |
147 | [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( ++reported * 5 )) | 147 | [ 1 -eq $(( ( table_file * 20 ) / number_of_files > reported )) ] && printf "%d%% " $(( (reported+=1) * 5 )) |
148 | table_file=`printf %0${filename_len}d ${table_file}` | 148 | table_file=`printf %0${filename_len}d ${table_file}` |
149 | done | 149 | done |
150 | printf "done.\n" | 150 | printf "done.\n" |
@@ -206,11 +206,11 @@ handle_new_format() { | |||
206 | # Do enumerations with builtin shell tools. Unfortunally neither | 206 | # Do enumerations with builtin shell tools. Unfortunally neither |
207 | # jot nor seq are standards | 207 | # jot nor seq are standards |
208 | printf "Splitting decompressed chunks into their columns (11 total) ... 1, " | 208 | printf "Splitting decompressed chunks into their columns (11 total) ... 1, " |
209 | f=0; while [ $f -lt $rows ]; do printf "file_%05X " $(( f++ * 11)); done | xargs cat | xxd -ps -c1 > column_0 | 209 | f=-1; while [ $f -lt $rows ]; do printf "file_%05X " $(( (f+=1) * 11)); done | xargs cat | xxd -ps -c1 > column_0 |
210 | 210 | ||
211 | for column in 1 2 3 4 5 6 7 8 9 10; do | 211 | for col in 1 2 3 4 5 6 7 8 9 10; do |
212 | printf "%d, " $(( column + 1 )) | 212 | printf "%d, " $(( col + 1 )) |
213 | f=0; while [ $f -lt $rows ]; do printf "file_%05X " $(( column + f++ * 11 )); done | xargs cat | tr '\n\0' '\t\n' > column_${column} | 213 | f=-1; while [ $f -lt $rows ]; do printf "file_%05X " $(( col + (f+=1) * 11 )); done | xargs cat | tr '\n\0' '\t\n' > column_${col} |
214 | done | 214 | done |
215 | printf "done.\n" | 215 | printf "done.\n" |
216 | 216 | ||