config.tests/unix/makeabs
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 15:10:48 +0300 (2010-07-06)
changeset 30 5dc02b23752f
parent 0 1918ee327afb
permissions -rw-r--r--
Revision: 201025 Kit: 2010127
#!/bin/sh

FILE="$1"
RES="$FILE"

CUT_ARG="-b1"
if [ `uname -s` = "QNX" ]; then
    # QNX does not understand "-b1"
    CUT_ARG="-c1"
fi

if [ `echo $FILE | cut $CUT_ARG` = "/" ]; 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