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

Using Glob Patterns in File Operations and Dealing with No Match Found Error #10673

Closed
atahabaki opened this issue Oct 10, 2023 · 5 comments
Closed
Labels
file-system Related to commands and core nushell behavior around the file system glob-expansion Specific behavior around file-system globbing with regular commands or `glob` needs-triage An issue that hasn't had any proper look

Comments

@atahabaki
Copy link
Contributor

Describe the bug

Certain file operations checks glob pattern match on given parameter. But what if the file exists with that name? It fails, with 'No match(es) found'.

To solve:

We could either

  • re-implement the glob or
  • check if the target(s) exists before glob check on every fs operation.

I'm implementing the second approach on glob-prevents branch on my fork.

How to reproduce

  1. Create a file or folder that contains glob pattern symbols.
  2. Use filesystem operations such as mv,rm in them.
  3. File and folder exists but it is handled by glob. Therefore, there'll be no match.

Example

touch X[12].txt
rm X[12].txt

Expected behavior

Last command should be successful. Because of glob match check it will not. I'm working

Screenshots

No response

Configuration

key value
version 0.85.0
branch makepkg
commit_hash a6f62e0
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.72.1 (d5c2e9c34 2023-09-13) (Arch Linux rust 1:1.72.1-1)
cargo_version cargo 1.72.1
build_time 2023-09-22 08:35:37 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins

Additional context

No response

@atahabaki atahabaki added the needs-triage An issue that hasn't had any proper look label Oct 10, 2023
@amtoine amtoine added glob-expansion Specific behavior around file-system globbing with regular commands or `glob` file-system Related to commands and core nushell behavior around the file system labels Oct 10, 2023
@amtoine
Copy link
Member

amtoine commented Oct 10, 2023

@bobhy
Copy link
Contributor

bobhy commented Oct 10, 2023

I think this is a dupe of #10571, for which I'm working on a fix #10557.

@fdncred
Copy link
Collaborator

fdncred commented Oct 10, 2023

This works right now by escaping the globbing characters.

rm X[[]12].txt

@atahabaki
Copy link
Contributor Author

This works right now by escaping the globbing characters.

rm X[[]12].txt

escaping syntax is not covered in glob --examples. I didn't know how to escape. That's why I created a draft PR #10677 . Now, I'm gonna close it. 'Cause I'd prefer the #10557 approach.

I'd consider this issue as: the dupplication of #9310, #10571. Thanks in advance.

@fdncred
Copy link
Collaborator

fdncred commented Oct 10, 2023

Sounds good. I just wanted to share that "trick" so you knew.

@fdncred fdncred closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
file-system Related to commands and core nushell behavior around the file system glob-expansion Specific behavior around file-system globbing with regular commands or `glob` needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

No branches or pull requests

4 participants