blob: 9d6610814fbd6527482520601adae552113920f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
|