Bug 12616 - realpath/readlink is incompatible with coreutils implementation
Summary: realpath/readlink is incompatible with coreutils implementation
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.31.x
Hardware: All Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-07 20:25 UTC by Koichi Nakashima
Modified: 2020-03-07 20:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Koichi Nakashima 2020-03-07 20:25:25 UTC
Version: https://git.busybox.net/busybox/commit/?id=9aa751b08ab03d6396f86c3df77937a19687981b

----------------
Repro 1:
$ cd /tmp
$ ln -s no-such-a-file symlink

Coreutils (expected):
$ readlink -f /tmp/symlink
/tmp/no-such-a-file
$ realpath /tmp/symlink
/tmp/no-such-a-file

Busybox (incorrect):
$ readlink -f symlink
/tmp/symlink
$ realpath symlink
/tmp/symlink

----------------
Repro 2:
$ cd /usr/bin

Coreutils (expected):
$ readlink -f ../.../
/usr/...
$ realpath ../.../
/usr/...

Busybox (incorrect):
$ readlink -f ../.../
(none, exit status: 1) 
$ realpath ../.../
realpath: ../...: No such file or directory

----------------
Repro 3:

Coreutils (expected):
$ readlink -f /no-such-a-file
/no-such-a-file
$ realpath /no-such-a-file
/no-such-a-file

Busybox (incorrect):
$ readlink -f /no-such-a-file
(none, exit status: 1) 
$ realpath /no-such-a-file
realpath: : No such file or directory

----------------
Repro 4:
$ cd /

Coreutils (expected):
$ readlink -f /./no-such-a-file
/no-such-a-file
$ realpath /./no-such-a-file
/no-such-a-file

Busybox (incorrect):
$ readlink -f /./no-such-a-file
//no-such-a-file
$ realpath /./no-such-a-file
//no-such-a-file

----------------
Repro 5:
$ cd /
$ ln -s ./no-such-a-file2 /symlink2

Coreutils (expected):
$ readlink -f symlink2
/no-such-a-file2
$ realpath symlink2
/no-such-a-file2

Busybox (incorrect):
$ readlink -f /symlink2
/./no-such-a-file2
$ realpath symlink2
/./no-such-a-file2

----------------
This is a different bug from
- https://bugs.busybox.net/show_bug.cgi?id=11021
- https://bugs.busybox.net/show_bug.cgi?id=11956

This bug was found during the development of https://github.com/ko1nksm/readlinkf. It may be your help.