3 # Find a relative path from "to" to "from"
4 # ie. a path which can be used in "from" to get to "to".
5 # Example: $0 x/y/z a/b -> ../../../a/b
6 # Example: $0 /x/y/z a/b -> /x/y/z
7 # Example: $0 x/../y/z a/b -> ../../a/b
8 # Example: $0 x/y/../z a/b -> ../../a/b
9 # Example: $0 x/./y/z a/b -> ../../../a/b
10 # Example (in x): $0 ../y/z a/b -> ../../x/a/b
23 if (substr(from,1,1)=="/")
29 if (!match(from,/^[^/]+/))
35 dir=substr(from,RSTART,RLENGTH);
36 from=substr(from,RSTART+RLENGTH+1);
41 if (dir != "." && dir != "..")
49 cmd="cd " cddir " ; pwd";
58 prefix=substr(prefix,4);