[Toybox] realpath --relative-to

enh enh at google.com
Tue Jun 9 14:22:57 PDT 2020


is there anything clever about realpath --relative-to, or is it just a
textual thing? something like:

  do the regular realpath work
  if (FLAG(relative_to)) {
    if (result starts-with relative_to_str) {
      remove prefix
    } else {
      add prefix of "../" * number of directories in relative_to_str
    }
  }

apparently there are some uses in the kernel build.

i guess it's a little cleverer than described above because you have
to clean the --relative-to path:

~$ realpath --relative-to=/////etc/// /etc/passwd
passwd
~$ realpath --relative-to=/../etc/// /etc/passwd
passwd
~$



More information about the Toybox mailing list