summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/makeabs
blob: c415cc7bdad1cbb778dbc3729990485cb3ec03ad (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
#!/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