Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / pharo / wrapper / pharo-vm.sh
blobd5bd1a2d80186a516c9b1acd5e62bc130ad1b8d2
1 #!/bin/sh
2 # This is based on the script by David T. Lewis posted here:
3 # http://lists.squeakfoundation.org/pipermail/vm-dev/2017-April/024836.html
5 # VM run utility script
6 # usage: run <myimage>
8 # Select a VM and run an image based on the image format number
10 PATH=$PATH:@file@/bin
12 # Search for the image filename in the command line arguments
13 for arg in $* $SQUEAK_IMAGE; do
14 case ${arg} in
15 -*) # ignore
17 *) # either an option argument or the image name
18 if test -e ${arg}; then
19 magic=$(file -L -b -m @magic@ "$arg")
20 case "$magic" in
21 "Smalltalk image V3 32b"*)
22 image=${arg}
23 vm=@cog32@/bin/pharo-cog
25 "Smalltalk image Spur 32b"*)
26 image=${arg}
27 vm=@spur32@/bin/pharo-spur
29 "Smalltalk image Spur 64b"*)
30 if [ "@spur64vm@" == "none" ]; then
31 echo "error: detected 64-bit image but 64-bit VM is not available" >&2
32 exit 1
34 image=${arg}
35 vm=@spur64@/bin/pharo-spur64
37 esac
40 esac
41 done
43 # Print a message to explain our DWIM'ery.
44 if [ -n "$image" ]; then
45 echo "using VM selected by image type."
46 echo " image: $image"
47 echo " type: $magic"
48 echo " vm: $vm"
49 else
50 echo "using default vm; image type not detected"
51 vm=@cog32@/bin/pharo-cog
54 # Run the VM
55 set -f
56 exec -- "${vm}" "$@"