Support #4891
closedhedge case?: file:copy deletes destination
0%
Description
Hi, I am running SaxonPE9-9-1-8J under ubuntu (from a windows10 unix subsystem bash shell) and I found this:
when:
<xsl:variable name="src" select="file:///dir/File.ext"/>
<xsl:variable name="dst" select="file:///dir/file.ext"/>
I.e. $dst=lower-case($src)
then:
<xsl:value-of select="file:move($src, $dst)"/>
deletes the file at $dst
The easy workaround is:
<xsl:variable name="dst_tmp" select="concat($dst, '_tmp')"/>
<xsl:value-of select="file:move($src, $dst_tmp)"/>
<xsl:value-of select="file:move($dst_tmp, $dst)"/>
but maybe this shoud be investigated.
I have not tried under a regular bash shell, so maybe this is specific to Windows10 unix subsystem
Thanks
Updated by Michael Kay about 3 years ago
- Status changed from New to In Progress
This seems entirely consistent with the specification, which states (in ยง4.11):
if $target is a file, it will be overwritten
There are many other ways of having two different URIs that refer to the same file, for example by using non-normalised URIs, query parameters, or symbolic links. I'm not sure there is even a reliable way of discovering that two URIs refer to the same file.
Updated by Giuseppe Bonelli about 3 years ago
Yes, I agree, but I assumed that uris are case sensitive.
Or they aren't?
Updated by Michael Kay about 3 years ago
Correct, URI's are case sensitive. So file:///c:/x.xml
and file:///C:/X.XML
are two different URIs. But (on Windows) they are different names for the same underlying resource. You can have many other URIs also referring to this resource, for example if it is on an HTTP server then http://localhost/x.xml
might be the same resource; and if you delete the resource using any of these URIs, the resource will be gone and the other URIs will fail to find it. A name is not the same as the thing it refers to; things can have more than one name.
Updated by Giuseppe Bonelli about 3 years ago
Ok, agreed.
I was assuming that a file name under the windows unix subsystem is case sensitive, but it seems it is not!
Thanks for the quick answer (and for saxonica).
regards
Updated by Michael Kay about 3 years ago
- Tracker changed from Bug to Support
- Status changed from In Progress to Closed
Marking as resolved; not a bug.
Please register to edit this issue