summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/makeabs
blob: f1d8a4056f2ccac2ac91e93c4bbf73ec9efa7ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

FILE="$1"
RES="$FILE"
if [ -z "${FILE##/*}" ]; then
    true
elif [ "$OSTYPE" = "msys" -a -z "${FILE##[a-zA-Z]:[/\\]*}" ]; then
    true
else
    RES="$PWD/$FILE"
fi
RES=$RES/
while true; do
    nres=`echo "$RES" | sed "s,/[^/][^/]*/\.\./,/,g; s,/\./,/,g"`
    test x"$nres" = x"$RES" && break
    RES=$nres
done
RES=`echo "$RES" | sed "s,//,/,g; s,/$,,"`
echo $RES #return