Skip to content
Snippets Groups Projects
Commit 17028220 authored by Christian Engwer's avatar Christian Engwer
Browse files

fixed canonicalpath, first try readlink, if it's a file use the real name

[[Imported from SVN: r4715]]
parent 879ed810
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,20 @@
set -e
# Get the canonical path (without using readlink)
# Does not work for weired file names
canonicalizepath(){
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalizepath path
echo Usage: canonicalname path > /dev/stderr
return 1
fi
local searchpath="$PATH:.:$(dirname $0)"
local prog=$(echo $0 | sed 's/.*\/\([-_a-zA-Z0-9]*\)$/\1/')
for i in `echo $searchpath | sed -e 's/:/ /g'`; do
if test -e "$i/$prog" ; then
canonicalpath="$i"
return 0
fi
done
echo "Error: no canonical path found"
exit 1
readlink $1 || echo "$(dirname $1)/$(basename $1)"
}
canonicalpath(){
if test $# -ne 1; then
echo Usage: canonicalpath path > /dev/stderr
return 1
fi
(cd $(dirname $(canonicalname $1)) && pwd)
}
if test "x$1" = "x--debug"; then
......@@ -32,8 +29,7 @@ fi
# Read the modules find part
canonicalizepath $0
. $canonicalpath/dunemodules.inc
. $(canonicalpath $0)/dunemodules.inc
###
......@@ -251,7 +247,7 @@ while test $# -gt 0; do
echo
exit 1;
fi
OPTS_FILE=$(cd $(dirname $(readlink -f $arg)); pwd)/$(basename $arg)
OPTS_FILE=$(canonicalpath $arg)/$(basename $arg)
if ! test -r "$OPTS_FILE"; then
usage
echo "ERROR: could not read opts file \"$OPTS_FILE\""
......
......@@ -9,22 +9,20 @@
set -e
# Get the canonical path (without using readlink)
canonicalizepath(){
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalizepath path
echo Usage: canonicalname path > /dev/stderr
return 1
fi
local searchpath="$PATH:.:$(dirname $0)"
local prog=$(echo $0 | sed 's/.*\/\([-_a-zA-Z0-9]*\)$/\1/')
for i in `echo $searchpath | sed -e 's/:/ /g'`; do
if test -e "$i/$prog" ; then
canonicalpath="$i"
return
fi
done
echo "Error: no canonical path found"
exit 1
readlink $1 || echo "$(dirname $1)/$(basename $1)"
}
canonicalpath(){
if test $# -ne 1; then
echo Usage: canonicalpath path > /dev/stderr
return 1
fi
(cd $(dirname $(canonicalname $1)) && pwd)
}
echo Dune project/module generator
......@@ -42,8 +40,7 @@ while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
MODULE="$PROJECT"
# Read the modules find part
canonicalizepath $0
. $(cd $canonicalpath; pwd)/dunemodules.inc
. $(canonicalpath $0)/dunemodules.inc
if [ "$MODULES" = "" ]; then
find_modules .
......
......@@ -2,22 +2,20 @@
set -e
# Get the canonical path (without using readlink)
canonicalizepath(){
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalizepath path
echo Usage: canonicalname path > /dev/stderr
return 1
fi
local searchpath="$PATH:.:$(dirname $0)"
local prog=$(echo $0 | sed 's/.*\/\([-_a-zA-Z0-9]*\)$/\1/')
for i in `echo $searchpath | sed -e 's/:/ /g'`; do
if test -e "$i/$prog" ; then
canonicalpath="$i"
return 0
fi
done
echo "Error: no canonical path found"
exit 1
readlink $1 || echo "$(dirname $1)/$(basename $1)"
}
canonicalpath(){
if test $# -ne 1; then
echo Usage: canonicalpath path > /dev/stderr
return 1
fi
(cd $(dirname $(canonicalname $1)) && pwd)
}
version=0.1
......@@ -90,11 +88,8 @@ fi
# load mpi-config.m4
#
# Read the modules find part
canonicalizepath $0
eval "$(
m4 -I$canonicalpath/../m4/ <<EOF
m4 -I$(canonicalpath $0/../m4/) <<EOF
changequote([, ])
define([AC_DEFUN],[define([\$1],[\$2])])
define([AC_MSG_CHECKING],[
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment