File: simulate.sh

package info (click to toggle)
libchewing 0.10.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,040 kB
  • sloc: ansic: 7,031; python: 190; sh: 127; makefile: 44
file content (35 lines) | stat: -rwxr-xr-x 603 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

abort() {
    echo $@
    exit 1
}

do_simulate() {
    ./simulate
}

do_rand_simulate() {
     sort -R materials.txt | egrep -v "^#" > materials.txt-random
     do_simulate
}

if [ ! -f materials.txt ]; then
    abort "Error! file materials.txt doesn't exist."
fi
if [ ! -f simulate ]; then
    echo "program 'simulate' not found.  Try to make"
    make >/dev/null 2>/dev/null
    if test "$?" != "0"; then
        abort "Error! Fail to build simulate"
    fi
fi

clear
# Simply invoke simulate
if [ x"$1" = "xrandom" ]; then
    rm -f uhash.dat
    do_rand_simulate
else
    do_simulate
fi