`filename:join()` corner case (?)

Hi,
I am using Erlang/OTP 27.0.1. I came across a strange corner case related to the filename:join() function which does not seem to be documented here:
https://www.erlang.org/doc/apps/stdlib/filename.html#join/1

My question is if the filename:join() behaviour shown below is a feature or a bug…

$ erl
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V15.0.1 (press Ctrl+G to abort, type help(). for help)
...
2> filename:join(["", "etc/path"]).
"/etc/path"

Thanks,
Cristian

It seems like consistent behaviour to me…

1> filename:join(["abc", "def/ghi"]).
"abc/def/ghi"
2> filename:join(["ab", "def/ghi"]).
"ab/def/ghi"
3> filename:join(["a", "def/ghi"]).
"a/def/ghi"
4> filename:join(["", "def/ghi"]).
"/def/ghi"
5>

Oh… I see what you mean now…

10> filename:join(["", "", "def/ghi", ""]).
"/def/ghi"

Yeah… empty paths are “swallowed” everywhere else… :thinking:

Yes, if in the list of paths parameter of filename:join/1 there is one empty string before one string which contains an relative path, it “transforms” the path from relative to absolute… :open_mouth:

FWIW in Elixir it is:

iex> Path.join(["", "etc/path"])
"etc/path"

I couldn’t easily find rationale. I’d be curious what a property-based test for path join would look like and whether it could say something about this edge case!