Pádraig Brady wrote:
...
>> Reading only the documentation for --relative-base=FILE,
>> I am not sure how it works:
>>
>> `--relative-base=FILE'
>> Ensure both the `--relative-to' and processed files are
>> subdirectories of FILE, or otherwise output the absolute file name.
>> Note this option honors the `-m' and `-e' options pertaining to
>> file existence.
>>
>> An example or two would help a lot.
>
> I'll add something along these lines:
Thanks.
> $ realpath --relative-to=/usr /tmp /usr/bin
> ../tmp
I see two lines of output. I guess you missed the latter?
$ ./realpath --relative-to=/usr /tmp /usr/bin
../tmp
bin
> $ realpath --relative-base=/usr --relative-to=/usr /tmp /usr/bin
> /tmp
> bin
Good. That makes it clearer.
The "Ensure" threw me. It's not really ensuring it.
Maybe something like this?
`--relative-base=BASE'
When both the `--relative-to' file and a listed FILE are
descendants of BASE, print a BASE-relative name for FILE.
Otherwise, print FILE's absolute name.
Note this option honors the `-m' and `-e' options pertaining to
file existence.
There's probably more to consider when the --relative-to= and
--relative-base= specified names are different, but I haven't
thought about that.