On 9/16/23 00:45, Junio C Hamano wrote:
Mark Levedahl <mlevedahl@xxxxxxxxx> writes:
I think a simpler fix is just to examine the number of path components
- more than one means a relative or absolute command (/foo splits into
two parts). The below works for me on Linux.
That is clever, but I cannot convince myself that it is not too
clever for its own sake. The "pathtype" thing Dscho used in his
original is documented to be aware of things like "C:\path\name",
but I didn't re-read the Tcl manual page too carefully to know what
"file split" does for such pathname to be certain.
The manual does not talk about Windows explicitly. From
https://www.tcl.tk/man/tcl/TclCmd/file.html#M35
*file split */name/
Returns a list whose elements are the path components in /name/. The
first element of the list will have the same path type as /name/.
All other elements will be relative. Path separators will be
discarded unless they are needed to ensure that an element is
unambiguously relative. For example, under Unix
*file split* /foo/~bar/baz
returns “*/ foo ./~bar baz*” to ensure that later commands that use
the third component do not attempt to perform tilde substitution.
So, there is hope c:\foo will split into c: foo, or c:\ foo, but testing
on Windows is needed. Really need Dscho or someone else from g4w to help
out here.