Skip to content

[Windows] Writing Data to "CON" path creates "CON" file in CWD instead of printing to stdout #1431

@jmschonfeld

Description

@jmschonfeld

Describe the bug
Writing Data to the path/URL "CON" results in a "CON" file being created in the CWD instead of printing that data to stdout

To Reproduce
Given the following unit test in swift-foundation

    #if os(Linux) || os(Windows)
    @Test
    #else
    @Test(.disabled("This test is not applicable on this platform"))
    #endif
    func writeToSpecialFile() throws {
        #if os(Windows)
        let path = URL(filePath: "CON", directoryHint: .notDirectory)
        #else
        let path = URL(filePath: "/dev/stdout", directoryHint: .notDirectory)
        #endif
        #expect(throws: Never.self) {
            try Data("Output to STDOUT\n".utf8).write(to: path)
        }
    }

it creates the file "CON" in the CWD instead of printing "Output to STDOUT" to stdout

Expected behavior
As was the case in previous releases IIRC, I expect this to output to STDOUT and not write to the CWD

Configuration (please complete the following information):

  • Swift Version: main branch of swift-foundation with the June 22nd Windows main snapshot toolchain
  • OS: Windows
  • OS Version: Windows 10

Regression information:
If applicable, please list older versions where this issue did not occur.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions