equal
deleted
inserted
replaced
|
1 #!/bin/sh |
|
2 |
|
3 FILE="$1" |
|
4 RES="$FILE" |
|
5 |
|
6 CUT_ARG="-b1" |
|
7 if [ `uname -s` = "QNX" ]; then |
|
8 # QNX does not understand "-b1" |
|
9 CUT_ARG="-c1" |
|
10 fi |
|
11 |
|
12 if [ `echo $FILE | cut $CUT_ARG` = "/" ]; then |
|
13 true |
|
14 else |
|
15 RES="$PWD/$FILE" |
|
16 test -d "$RES" && RES="$RES/" |
|
17 RES=`echo "$RES" | sed "s,/\(\./\)*,/,g"` |
|
18 |
|
19 # note: this will only strip 1 /path/../ from RES, i.e. given /a/b/c/../../../, it returns /a/b/../../ |
|
20 RES=`echo "$RES" | sed "s,\(/[^/]*/\)\.\./,/,g"` |
|
21 |
|
22 RES=`echo "$RES" | sed "s,//,/,g" | sed "s,/$,,"` |
|
23 fi |
|
24 echo $RES #return |
|
25 |