Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS/Linux: Allow \ in file names #212740

Closed
Tracked by #212907
ElectricRCAircraftGuy opened this issue May 14, 2024 · 8 comments
Closed
Tracked by #212907

macOS/Linux: Allow \ in file names #212740

ElectricRCAircraftGuy opened this issue May 14, 2024 · 8 comments
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug file-io File I/O insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux macos Issues with VS Code on MAC/OS X verified Verification succeeded
Milestone

Comments

@ElectricRCAircraftGuy
Copy link
Contributor

ElectricRCAircraftGuy commented May 14, 2024

Does this issue occur when all extensions are disabled?: Yes/No yes

  • VS Code Version:

    Version: 1.89.1
    Commit: dc96b83
    Date: 2024-05-07T05:16:23.416Z
    Electron: 28.2.8
    ElectronBuildId: 27744544
    Chromium: 120.0.6099.291
    Node.js: 18.18.2
    V8: 12.0.267.19-electron.0
    OS: Linux x64 6.5.0-28-generic

  • OS Version:

    Ubuntu 22.04

Steps to Reproduce:

  1. Create a file in Linux named C:\Program Files\Git\git-bash.exe at path ~/bin:

    touch ~/bin/"C:\Program Files\Git\git-bash.exe"
  2. Now try to open it with VSCode to edit it:

    code ~/bin/"C:\Program Files\Git\git-bash.exe"
    
    # to be sure, open with extensions disabled too
    code --disable-extensions ~/bin/"C:\Program Files\Git\git-bash.exe"

    It doesn't open the file! I see this instead (with all "Recent" filenames redacted from the image):

    330577265-9152902b-d1b6-4143-80ca-7273e82d6173

  3. It doesn't open! I have to open it in another text editor, such as Sublime Text, instead:

    subl ~/bin/"C:\Program Files\Git\git-bash.exe"

Note: for anyone wondering why in the world we woud have a Linux file that looks like a Windows path, it's because I am in a development environment where our team is mixed Linux and Windows users, and there are tricks where I can make the same script run on both systems by putting this inside that file, for instance, to emulate on Linux loading Git Bash on Windows:

File ~/bin/"C:\Program Files\Git\git-bash.exe":

#!/usr/bin/env bash

# This is a wrapper to simulate Windows's Git Bash terminal in Linux

bash "$@"

See here: Stack Overflow: How to configure a preBuildSteps.sh Bash script that runs as part of the pre-build process in the MPLAB X IDE on both Windows and Linux

I just need VSCode to be able to edit such files, now. Meanwhile, Sublime Text works fine on these files.

@ElectricRCAircraftGuy
Copy link
Contributor Author

Related, but for folders instead: #207775

@ElectricRCAircraftGuy
Copy link
Contributor Author

Note that the only chars not allowed in filenames and paths in Linux are / (forward slash) and \0 (null terminator). See:

  1. https://stackoverflow.com/a/31976060/4561887
  2. https://stackoverflow.com/a/1311070/4561887

@bpasero bpasero added macos Issues with VS Code on MAC/OS X linux Issues with VS Code on Linux file-io File I/O feature-request Request for new features or functionality and removed triage-needed labels May 15, 2024
@bpasero bpasero added this to the Backlog milestone May 15, 2024
@bpasero bpasero changed the title Cannot open or edit valid files on Linux with backslashes in names; example of a text filename on Linux: C:\Program Files\Git\git-bash.exe macOS/Linux: Allow \ in file names May 15, 2024
@bpasero
Copy link
Member

bpasero commented May 15, 2024

This is because of:

const UNIX_INVALID_FILE_CHARS = /[\\/]/g;

The discussion in #22899 indicates that this is unfortunately not straight forward to support, but keeping as feature request.

@bpasero
Copy link
Member

bpasero commented May 15, 2024

Hm, I cannot reproduce the original issue so maybe meanwhile we could do this 🤔

@bpasero bpasero self-assigned this May 15, 2024
@bpasero bpasero modified the milestones: Backlog, May 2024 May 15, 2024
@bpasero
Copy link
Member

bpasero commented May 15, 2024

PR up #212810

I hope this does not break something, but I am quite confident it should be fine because we do allow to create file names with backslash on Linux and Windows (due to a bug actually where we did not properly validate the file name) using the VS Code explorer 🤞

//cc @alexr00 where the validation method is used for simple file dialog which likely fixes #207775

@ElectricRCAircraftGuy
Copy link
Contributor Author

Hm, I cannot reproduce the original issue

@bpasero , you mean the original issue in #22899?

Or you mean my issue which I describe in the first post above?

@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label May 16, 2024
@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality labels May 16, 2024
@ElectricRCAircraftGuy
Copy link
Contributor Author

ElectricRCAircraftGuy commented May 16, 2024

@VSCodeTriageBot VSCodeTriageBot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels May 17, 2024
@bpasero bpasero added the author-verification-requested Issues potentially verifiable by issue author label May 17, 2024
@VSCodeTriageBot
Copy link
Collaborator

This bug has been fixed in the latest release of VS Code Insiders!

@ElectricRCAircraftGuy, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version a48f464 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@aeschli aeschli added the verified Verification succeeded label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug file-io File I/O insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux macos Issues with VS Code on MAC/OS X verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants