blob: d2f65d19e9c8c483087ccb1c211a9a90f95d47e1 (
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
26
27
|
#!/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
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
|