summaryrefslogtreecommitdiff
path: root/res/fqterm.sh
blob: d9e1d2c0f7b1b797e97fcc04b1b795759b08ab79 (plain)
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
#!/bin/sh

this_name="$0"

current_directory=`/bin/pwd`

cd `dirname "$this_name"`
base_name=`basename "$this_name"`
bin_directory=`/bin/pwd`

# get the real file name in case it's a symbolic link.
while [ -h "$this_name" ]; do
  this_name=`/bin/ls -l "$base_name" | sed -e 's/^.* -> //' `
  cd `dirname "$this_name"`
  base_name=`basename "$this_name"`
  bin_directory=`/bin/pwd`
done

# setup environment variables and then run the real executable.
if [ -x "$base_name".bin ]; then
  cd "$current_directory"
  export FQTERM_PREFIX=`dirname "$bin_directory"`
  export FQTERM_RESOURCE="$FQTERM_PREFIX/share/FQTerm"
  "$bin_directory/$base_name.bin" "$@"
  exit $?
else
  cd "$current_directory"
  echo "Error, cannot find $base_name."
  exit 2
fi