summaryrefslogtreecommitdiffstats
path: root/Cancer/query/realpath/install
blob: 74671c81c0502cf99ec224a033fa8d4131a67869 (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
31
32
33
34
35
36
37
38
39
40
41
#! /bin/sh
set -euf

cd `dirname $0`

target=../../bin/realpath

findexe() {
  OLDIFS="$IFS"
  IFS=:
  for d in $PATH; do
    f="$d/$1"
    if test -f "$f" -a -x "$f"; then
      echo $f
      IFS="$OLDIFS"
      return
    fi
  done
  IFS="$OLDIFS"
  ! :
}

if exe="`findexe readlink`" && $exe -f install | grep -q /install$; then
  ! test -e $target || rm $target
  cat > $target <<EOF
#! /bin/sh -euf
exec $exe -f "\${1-\$file_name}"
EOF
  chmod +x $target
  echo '//query/realpath: install readlink' >&2
  exit
fi

if type ruby 1>/dev/null 2>/dev/null; then
  ln -snf ../query/realpath/src/realpath.rb $target
  echo '//query/realpath: install realpath.rb' >&2
  exit
fi

echo 'Error 2: your system is made of stupid!'
exit 23