Stephan Witt wrote: > Andreas Vox wrote: >> Angus Leeming <[EMAIL PROTECTED]> writes: >> >> >>>>what about [ `dirname "$1"` -ef `dirname "$2"` ] ? >>> >>>"test -e FOO" is a bash extension. >>>Also, "dirname" does nothing more than strip everything after the final >>>'/' character. "/foo/bar/../baz.cpp" and "/foo/baz.cpp" will appear to >>>be in different directories. >> >> >> Correct for dirname, but -ef as well as cd+pwd will use the true >> directory. >> >> Also I found '-ef' documented in the man page for ksh (SunOS 5.8) and >> BSD test, so I think it should be available on most platforms. > > Hi Andreas, > > yes, on Solaris it's available for ksh - but not for sh. > (The standard shell for scripting and used by make.) > So it's not true to say it's available for all (or most) platforms.
I think we're getting a little too involved with generics here, given that this script is to be used to move .fig files into the temp directory only. I think that the test below should do the job and should be portable. PRESENT_DIR=$PWD cd `dirname "$1"` || exit $? FROM_DIR=$PWD cd `dirname "$2"` || exit $? TO_DIR=$PWD cd "$PRESENT_DIR" test "$FROM_DIR" = "$TO_DIR" && { # The "to" and "from" files are in the same directory. cp "$1" "$2" exit $? } -- Angus