The behaviour of cwk_path_join should be similar to running cd on the first argument, and cd on the last argument directly afterwards.
We can see this works with simple statements, like joining together hello and world:
Output of cwk_path_join: hello/world
Output of os.path.join from Python: hello/world
Output of two cds: hello/world
But, if we try to do something more subtle, like joining together /hello and /world, cwalk fails catastrophically:
Output of cwk_path_join: /hello/world (See https://likle.github.io/cwalk/reference/cwk_path_join.html - This flaw is even demonstrated in the documentation!)
Output of os.path.join from Python: /world
Output of two cds: /world
So, why is this happening? It seems that cwk_path_join doesn't actually "walk" or "separate cd" as it is intended to, but rather word-for-word smashes the two paths together.
Unless there is an alternative function that does this properly, cwk_path_join should NOT operate like this. Every argument to cwk_path_join should operate like a separate, sequenced cd.
If I run cd /hello and then cd /world, I end up in /world, because of the /. I do not end up in /hello/world. If I used /hello and then ./world (or just world), it would be /hello/world, but I did not do this.
Unreliable behaviour of cwk_path_join makes this library completely unusable for many people. I would suggest testing your function against Python's os.path functions.
The behaviour of cwk_path_join should be similar to running
cdon the first argument, andcdon the last argument directly afterwards.We can see this works with simple statements, like joining together
helloandworld:Output of cwk_path_join:
hello/worldOutput of os.path.join from Python:
hello/worldOutput of two
cds:hello/worldBut, if we try to do something more subtle, like joining together
/helloand/world, cwalk fails catastrophically:Output of cwk_path_join:
/hello/world(See https://likle.github.io/cwalk/reference/cwk_path_join.html - This flaw is even demonstrated in the documentation!)Output of os.path.join from Python:
/worldOutput of two
cds:/worldSo, why is this happening? It seems that cwk_path_join doesn't actually "walk" or "separate cd" as it is intended to, but rather word-for-word smashes the two paths together.
Unless there is an alternative function that does this properly, cwk_path_join should NOT operate like this. Every argument to cwk_path_join should operate like a separate, sequenced cd.
If I run
cd /helloand thencd /world, I end up in/world, because of the/. I do not end up in/hello/world. If I used/helloand then./world(or justworld), it would be/hello/world, but I did not do this.Unreliable behaviour of cwk_path_join makes this library completely unusable for many people. I would suggest testing your function against Python's os.path functions.