Skip to content

Warn on use of Windows DOS devices in paths #8511

@ChrisDenton

Description

@ChrisDenton

What it does

If the user uses a bare dos device name such as aux, windows will convert it to \\.\aux (the aux device). This may be surprising. Clippy could warn the user and suggest they explicitly use \\.\aux if that was intended. Using .\aux could also suppress this lint.

The DOS device names are (case insensitive):

  • AUX
  • CON
  • CONIN$
  • CONOUT$
  • COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM², COM³, COM¹
  • LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT², LPT³, LPT¹
  • NUL
  • PRN

Lint Name

bare_dos_device_name

Category

suspicious

Advantage

Avoids unexpected and surprising path transformations.

Drawbacks

This is platform specific behaviour.

Example

File::open("aux");

Could be written as:

File::open(r"\\.\aux");

Or

File::open("./aux");

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions