summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/makeabs
diff options
context:
space:
mode:
Diffstat (limited to 'config.tests/unix/makeabs')
-rwxr-xr-xconfig.tests/unix/makeabs19
1 files changed, 19 insertions, 0 deletions
diff --git a/config.tests/unix/makeabs b/config.tests/unix/makeabs
new file mode 100755
index 0000000..9d66108
--- /dev/null
+++ b/config.tests/unix/makeabs
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+FILE="$1"
+RES="$FILE"
+
+if [ `echo $FILE | cut -b1` = "/" ]; then
+ true
+else
+ RES="$PWD/$FILE"
+ test -d "$RES" && RES="$RES/"
+ RES=`echo "$RES" | sed "s,/\(\./\)*,/,g"`
+
+# note: this will only strip 1 /path/../ from RES, i.e. given /a/b/c/../../../, it returns /a/b/../../
+ RES=`echo "$RES" | sed "s,\(/[^/]*/\)\.\./,/,g"`
+
+ RES=`echo "$RES" | sed "s,//,/,g" | sed "s,/$,,"`
+fi
+echo $RES #return
+