File: image2script

package info (click to toggle)
scsh 0.5.1-2
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 6,540 kB
  • ctags: 8,656
  • sloc: lisp: 39,346; ansic: 13,466; sh: 1,669; makefile: 624
file content (48 lines) | stat: -rwxr-xr-x 1,274 bytes parent folder | download
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
#!/bin/sh -

binary=$1
shift

if [ `echo $binary | wc -c` -gt 28 ] ; then
    echo "#!/bin/sh -"
    echo exec $binary $* -i '"$0"' '"$@"'

elif [ $# -gt 0 ] ; then
    echo '#!'$binary \\
    echo $* -i

else echo '#!'$binary -i
fi

exec cat


# This program reads an S48 image from stdin and turns it into
# an executable by prepending a #! prefix. The vm and its
# args are passed to this program on the command line.
#
# If the vm binary is 27 chars or less, then we can directly
# execute the vm with one of these scripts:
#     No args:
#         image2script /usr/local/bin/svm <image
#     outputs this script:
#	  #!/usr/local/bin/svm -i
#	  ...image bits follow...
#    
#     Args:
#         image2script /usr/bin/svm -h 4000000 -o /usr/bin/svm <image
#     outputs this script:
#	  #!/usr/bin/svm \
#	  -h 4000000 -o /usr/bin/svm -i
#	  ...image bits follow...
#
# The exec system call won't handle the #! line if it contains more than
# 32 chars, so if the vm binary is over 28 chars, we have to use a /bin/sh
# trampoline.
#     image2script /user1/lecturer/shivers/vc/scsh/s48/lib/svm -h 4000000 < ...
# outputs this script:
#     #!/bin/sh -
#     exec /user1/lecturer/shivers/vc/scsh/s48/lib/svm -h 4000000 -i $0 $*
#     ...image bits follow...
#
# 	-Olin