forked from ablevm/forth-imgld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imgld
executable file
·61 lines (50 loc) · 844 Bytes
/
imgld
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
set -e
usage() {
echo "usage: $(basename "$0") [-h] [-b base] [-o outfile] infile ..." >&2
exit 1
}
boptarg=
ooptarg=
while getopts hb:o: ch; do
case "$ch" in
b)
if [ ! -z "$boptarg" ]; then
usage
fi
boptarg="$OPTARG"
;;
o)
if [ ! -z "$ooptarg" ]; then
usage
fi
ooptarg="$OPTARG"
;;
*)
usage
;;
esac
done
shift $(($OPTIND - 1))
if [ $# = 0 ]; then
usage
fi
if [ -z "$boptarg" ]; then
boptarg=262144
fi
if [ -z "$ooptarg" ]; then
ooptarg="a.img"
fi
. "$(dirname "$0")/imgld.subr"
include() {
if [ "${file#*.}" = "scr" ]; then
scr -r "$file" "$name.blk"
size=$(wc -c < "$name.blk")
fi
img -s $addr -i $size "$ooptarg" < "$name.blk"
able "$ooptarg" <<EOF | grep -v "^ ok" || true
: $name/ ( u1 - u2) # $(($addr / 1024)) + ;
bye
EOF
}
imgld include "$boptarg" "$@"