Bug 12616

Summary: realpath/readlink is incompatible with coreutils implementation
Product: Busybox Reporter: Koichi Nakashima <koichi>
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.31.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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.