bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong behavior of ``readlink -f''?


From: Thomas Schwinge
Subject: Re: Wrong behavior of ``readlink -f''?
Date: Wed, 20 Feb 2008 19:20:17 +0100
User-agent: Mutt/1.5.11

Hello!

On Wed, Feb 13, 2008 at 08:53:01AM +0100, Jim Meyering wrote:
> Thomas Schwinge <address@hidden> wrote:
> > $ readlink -f a/../a/f
> > $ echo $?
> > 1
> ...
> > readlink (GNU coreutils) 5.97
> >
> > Why doesn't it resolve the latter case just as the previous ones?
> > Because there are two symbolic links involved?  Or two times the same
> > one?  Strange.
> 
> Thanks for the report.
> That's because the code concluded it had encountered a cycle.
> The bug was fixed for coreutils-6.9.90 via a change to gnulib's
> canonicalize module.

For posterity.  I need this functionality in a somewhat portable build
environment, so this is what I'm using in `configure.ac' now:

#v+
[...]

[# Test for a readlink bug, see
# <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00126.html>.]
AC_MSG_CHECKING([for a suitable ``readlink -f'' program])
[mkdir readlink-test &&
mkdir readlink-test/a-long &&
: > readlink-test/a-long/f &&
ln -s a-long readlink-test/a &&
for READLINK_F in \
  'readlink -f' \
  realpath \
  false
do
  if
    $READLINK_F > /dev/null 2>&1 \
      readlink-test/a/../a/f 
  then
    break
  fi
done &&
rm -rf readlink-test &&
if [ "$READLINK_F" = false ]
then]
  AC_MSG_RESULT([none found, using own replacement])
  [READLINK_F='perl -e '\''use Cwd qw(abs_path); print abs_path $$ARGV[0];'\'
else]
  AC_MSG_RESULT([$READLINK_F])
[fi]
AC_SUBST([READLINK_F])

[...]
#v-


Regards,
 Thomas

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]