Browse code

On release: better relpath

Nat! authored on 21/11/2013 00:10:41
Showing 1 changed files
... ...
@@ -80,38 +80,9 @@ search_plist()
80 80
 }
81 81
 
82 82
 
83
-canonical_dirname()
83
+relpath()
84 84
 {
85
-   local dir
86
-
87
-   dir=`echo "$1" | sed '/\/$/s/^\(.*\)\/$/\1/'`
88
-   echo "$dir/"
89
-}
90
-
91
-
92
-rel_dir()
93
-{
94
-   local root
95
-   local dir
96
-   local count
97
-
98
-   root=`canonical_dirname $1`
99
-   dir=`canonical_dirname $2`
100
-
101
-   if [ "$dir" = "$root" ]
102
-   then
103
-      echo "."
104
-      return 0
105
-   fi
106
-
107
-   count=`echo -n "$1" | wc -c | awk '{ print $1 }'`
108
-   echo -n "$2" | awk "{ print substr( \$0, $count+1) }"
109
-}
110
-
111
-
112
-rel_pwd()
113
-{
114
-   rel_dir "$1" `pwd`
85
+   python -c "import os.path; print os.path.relpath('$1', '$2')"
115 86
 }
116 87
 
117 88
 
... ...
@@ -138,11 +109,11 @@ run()
138 138
    output="$random.stdout"
139 139
    errput="$random.stderr"
140 140
    errors=`basename $template .scion`.errors
141
-   pretty_template=`rel_pwd "$root"`/$template
141
+   pretty_template=`relpath "$root"`/$template `pwd`
142 142
 
143 143
    if [ "$VERBOSE" = "yes" ]
144 144
    then
145
-      echo `rel_pwd "$root"`/"$template"
145
+      echo `relpath "$root"`/"$template" `pwd`
146 146
    fi
147 147
 
148 148
    RUNS=`expr $RUNS + 1`