<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,17 +1,79 @@
 #!/bin/bash
 
+
+# some rubish code to locate the file ...
+
+simplify_path () {
+    curfile=$2
+    # simplify path by transforming &quot;//&quot; in &quot;/&quot;
+    pattern=&quot;/\{2,\}&quot;
+    while ( echo &quot;${curfile}&quot; | grep &quot;${pattern}&quot; &gt;/dev/null 2&gt;&amp;1 ) ; do
+      curfile=`echo &quot;${curfile}&quot; | sed -e s%&quot;${pattern}&quot;%&quot;/&quot;%`
+    done
+    # simplify path by removing &quot;./&quot;
+    pattern=&quot;/\./&quot;
+    while ( echo &quot;${curfile}&quot; | grep &quot;${pattern}&quot; &gt;/dev/null 2&gt;&amp;1 ) ; do
+      curfile=`echo &quot;${curfile}&quot; | sed -e s%&quot;${pattern}&quot;%&quot;/&quot;%`
+    done
+    # simplify path by transforming &quot;x/y/..&quot; in &quot;x&quot;
+    pattern=&quot;/[^/]\{1,\}/\.\./&quot;
+    while ( echo &quot;${curfile}&quot; | grep &quot;${pattern}&quot; &gt;/dev/null 2&gt;&amp;1 ) ; do
+      curfile=`echo &quot;${curfile}&quot; | sed -e s%&quot;${pattern}&quot;%&quot;/&quot;%`
+    done
+    eval &quot;$1=$curfile&quot;
+}
+
+locate () {
+    # Extract the path where this file is located (not where it is run
+    # from), taking care of dereferencing link and simplifying path.
+    # (code from FHT commented/set-in-function by LCE)
+    #
+    # locate $2 dereferencing link
+    curpath=$2
+    curfile=&quot;&quot;
+    while [ &quot;${curpath}&quot; != &quot;/&quot; ] ; do
+      if [ -h &quot;${curpath}&quot; ] ; then
+        lnk=`ls -l ${curpath} | sed -e s%&quot;^.\\{0,\\}[ ]-&gt;[ ]\\{1,\\}&quot;%%`
+        if ( echo &quot;${lnk}&quot; | grep &quot;^/&quot; &gt;/dev/null 2&gt;&amp;1 ) ; then
+          curpath=&quot;${lnk}&quot;
+        else
+          curpath=&quot;`dirname ${curpath}`/${lnk}&quot;
+        fi
+      else
+        curfile=&quot;/`basename ${curpath}`${curfile}&quot;
+        curpath=`dirname ${curpath}`
+      fi
+    done
+    simplify_path locfile $curfile
+    eval &quot;$1=$locfile&quot;
+}
+
+# extract application path
+if ( echo &quot;${0}&quot; | grep &quot;^/&quot; &gt;/dev/null 2&gt;&amp;1) ; then
+  CURPATH=&quot;${0}&quot;
+else
+  CURPATH=&quot;`pwd`/${0}&quot;
+fi
+locate CURFILE $CURPATH
+
+# directory where is the current file (file $0)
+ROOT=`dirname ${CURFILE}`/..
+
+
+# running the example start here
+
 EXIT=0
 OCAML_NODE_NAME=ocaml
 ERLANG_NODE_NAME=erl
 COOKIE=cookie
-PWD=`pwd`
+APP=$ROOT/carve.native
 
 # start erlang first (ensure epmd is running)
 echo; echo &quot;Test $0: Run and stop an erlang node to ensure epmd is running.&quot;
 erl -sname $ERLANG_NODE_NAME -setcookie $COOKIE -noshell -s init stop
 
 echo; echo &quot;Test $0: Run the ocaml server.&quot;
-./carve.native -name $OCAML_NODE_NAME -cookie $COOKIE &amp;
+$APP -name $OCAML_NODE_NAME -cookie $COOKIE &amp;
 OCAML_PID=$!
 
 echo; echo &quot;Test $0: Run erlang node to interact with ocaml node.&quot;
@@ -23,13 +85,13 @@ erl -sname $ERLANG_NODE_NAME -setcookie $COOKIE -noshell -eval &quot;
     {eocarving, OcamlNode} ! {self(), R1},
     {ok, Carver} = receive {R1, P} -&gt; {ok, P} after 1 -&gt; error end,
 
-    Carver ! {set_src_file, \&quot;$PWD/test/river.jpg\&quot;},
-    Carver ! {carve_h, -50, \&quot;$PWD/test/river_del50.jpg\&quot;},
-    Carver ! {carve_h, +50, \&quot;$PWD/test/river_add50.jpg\&quot;},
+    Carver ! {set_src_file, \&quot;$ROOT/test/river.jpg\&quot;},
+    Carver ! {carve_h, -50, \&quot;$ROOT/test/river_del50.jpg\&quot;},
+    Carver ! {carve_h, +50, \&quot;$ROOT/test/river_add50.jpg\&quot;},
 
-    Carver ! {set_src_file, \&quot;$PWD/test/horses.jpg\&quot;},
-    Carver ! {carve_h, -50, \&quot;$PWD/test/horses_del50.jpg\&quot;},
-    Carver ! {carve_h, +50, \&quot;$PWD/test/horses_add50.jpg\&quot;},
+    Carver ! {set_src_file, \&quot;$ROOT/test/horses.jpg\&quot;},
+    Carver ! {carve_h, -50, \&quot;$ROOT/test/horses_del50.jpg\&quot;},
+    Carver ! {carve_h, +50, \&quot;$ROOT/test/horses_add50.jpg\&quot;},
 
     Carver ! {self(), stop},
     ok = receive {Carver, stopped} -&gt; ok after 5000 -&gt; error end.</diff>
      <filename>test/carveh.sh</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c66066978c050b4679fe47114676b5374a522d6c</id>
    </parent>
  </parents>
  <author>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </author>
  <url>http://github.com/khigia/eocarve/commit/8a5f65b8175b27bfc0d792719485b5d31b72760a</url>
  <id>8a5f65b8175b27bfc0d792719485b5d31b72760a</id>
  <committed-date>2008-05-09T20:19:57-07:00</committed-date>
  <authored-date>2008-05-09T20:19:57-07:00</authored-date>
  <message>Make test/carveh.sh runnable from any folder location.</message>
  <tree>0cf6390b93e5fc67cd92febf8aed5a25c834172c</tree>
  <committer>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </committer>
</commit>
