summaryrefslogtreecommitdiffstats
path: root/query/realpath
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-12-30 17:38:02 +0100
committermakefu <github@syntax-fehler.de>2013-12-30 17:38:02 +0100
commitee33c348658a12a4e54281dc34eaca8639e247f8 (patch)
tree142ea8052af9e75886b6c71979eed302885ab22a /query/realpath
parentefef353ef2bf65ef6123fc699bce6c69fc37cfcc (diff)
parent11de3d6d4c62f7059cdb45992d7d0fec05dde0e4 (diff)
Merge branch 'master' of ssh://github.com/krebscode/painload
Diffstat (limited to 'query/realpath')
-rwxr-xr-xquery/realpath/install41
-rwxr-xr-xquery/realpath/src/realpath.rb10
2 files changed, 51 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
diff --git a/query/realpath/src/realpath.rb b/query/realpath/src/realpath.rb
new file mode 100755
index 00000000..8e19785b
--- /dev/null
+++ b/query/realpath/src/realpath.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+begin
+ $stdout.print File.realpath(ARGV[0])
+ $stdout.print "\n"
+rescue Exception => err
+ $stderr.print err
+ $stderr.print "\n"
+ exit 1
+end