Skip to content

realpath -m / readlink -m fail on a symlink loop #16325

Open

Description

@Socialpranker

With -m, GNU doesn't fail on a symlink loop, it just keeps the name. uutils errors out with "Too many levels of symbolic links".

cd "$(mktemp -d)"
ln -s b a; ln -s a b
realpath -m a      # GNU: $PWD/a        uutils: error, exit 1
realpath -m a/x    # GNU: $PWD/a/x      uutils: error, exit 1
readlink -m a      # GNU: $PWD/a        uutils: no output, exit 1

I'm not sure what the right fix is, though. Which name GNU keeps depends on the length of the loop: with p -> a added, realpath -m p gives $PWD/b. And on a loop that grows (foo -> foo/bar) GNU 9.11 on macOS never finishes, while uutils fails on purpose there (test_realpath_growing_loop). So I'm only reporting it, not sending a fix.

Activity

  1. DeepakRoy58 commented on Nov 16, 2026

    @DeepakRoy58
    Contributor

    hi, i would like to work on this. i will open a pr soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions