Root/gforth/files/gforth-wrapper.in

1#! /bin/sh
2#
3# Part of gforth package for OpenWrt: Wrapper to call check for and create
4# Gforth image before running executable.
5#
6# Copyright (C) 2010 David Kuehling <dvdkhlng TA gmx TOD de>
7#
8# License: GPLv3+, NO WARRANTY
9#
10dirname=$(dirname "$0")
11binary=$dirname/$(basename "$0").real
12
13GFORTH_LIB_DIR=/usr/lib/gforth/@PACKAGE_VERSION@
14GFORTH_FI=$GFORTH_LIB_DIR/gforth.fi
15
16# try to (re)generate the gforth.fi image file
17do_update(){
18    $dirname/gforth-update-image &> /dev/null
19    status=$?
20    [ $status = 0 ] && return 0
21
22cat<<EOF
23  Gforth image $GFORTH_FI
24  is missing and regeneration failed:
25
26  '$dirname/gforth-update-image'
27  aborted with exit code $status.
28
29  Try to re-run 'gforth-update-image' manually to
30  see what is wrong. Also please report this
31  problem to <discussion@lists.qi-hardware.com>
32  and/or <dvdkhlng ta gmx tod de>.
33
34  As a workaround, you can run a kernel-only Gforth
35  (with reduced functionality), using:
36
37  $binary -i @kernel_fi@
38EOF
39
40  exec false
41}
42
43if ! [ -f "$GFORTH_FI" ]; then
44    do_update
45fi
46
47# if everything is ok, we'll come here and run the actual Gforth executable
48# (gforth.real, gforth-fast.real etc.)
49exec "$binary" "$@"
50
51

Archive Download this file



interactive