summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@xso>2011-09-10 04:17:04 +0200
committertv <tv@xso>2011-09-10 04:17:04 +0200
commit2d9f62c76a9041f7deca892d4a9a19d309ce6dd3 (patch)
treeab0b48462b963962d25592bd17df92f209a3cc3f
parent0c72cef00ad7c1cb0cb672e03325f8b7b763e3c2 (diff)
//query/realpath/install: initial commit
-rwxr-xr-xquery/realpath/install41
1 files changed, 41 insertions, 0 deletions
diff --git a/query/realpath/install b/query/realpath/install
new file mode 100755
index 00000000..74671c81
--- /dev/null
+++ b/query/realpath/install
@@ -0,0 +1,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