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

glob command doesn't accept glob argument type #12716

Open
dedebenui opened this issue May 1, 2024 · 4 comments
Open

glob command doesn't accept glob argument type #12716

dedebenui opened this issue May 1, 2024 · 4 comments
Labels
🐛 bug Something isn't working glob-expansion Specific behavior around file-system globbing with regular commands or `glob` good first issue Good for newcomers inconsistent-behavior Behavior between different commands or types inconsistent/unexpected needs-triage An issue that hasn't had any proper look

Comments

@dedebenui
Copy link

Describe the bug

The glob command doesn't accept arguments that have been converted with into glob

How to reproduce

let pattern = [Desktop *] | path join | into glob
glob $pattern

I get the following error:

Error: nu::shell::cant_convert

  × Can't convert to string.
   ╭─[entry #8:2:6]
 1 │ let pattern = [Desktop *] | path join | into glob
 2 │ glob $pattern
   ·      ────┬───
   ·          ╰── can't convert glob to string
   ╰────

Expected behavior

I expect the same output as glob Desktop/*

╭───┬───────────────────────────╮
│ 0 │ /Users/john/Desktop/file1 │
│ 1 │ /Users/john/Desktop/file2 │
│ 2 │ /Users/john/Desktop/file3 │
╰───┴───────────────────────────╯

Screenshots

No response

Configuration

key value
version 0.93.0
major 0
minor 93
patch 0
branch main
commit_hash cb6d495
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-aarch64-apple-darwin
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-05-01 08:27:15 +02:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, system-clipboard, trash, which
installed_plugins

Additional context

The bug is not present with ls:

> let pattern = [Desktop *] | path join | into glob
> ls $pattern
╭───┬───────────────┬──────┬───────────┬────────────╮
 # │      name     │ type │   size    │  modified  │
├───┼───────────────┼──────┼───────────┼────────────┤
 0  Desktop/file1  file  213.3 KiB  2 days ago 
 1  Desktop/file2  file   45.5 KiB  a week ago 
 2  Desktop/file3  file   45.5 KiB  a week ago 
╰───┴───────────────┴──────┴───────────┴────────────╯
@dedebenui dedebenui added the needs-triage An issue that hasn't had any proper look label May 1, 2024
@fdncred
Copy link
Collaborator

fdncred commented May 1, 2024

Right, the glob command wants a string pattern, not a glob, and then it does its own globbing. The glob command uses a completely different globbing crate than anything else in nushell.

For your example, this should work, since it's asking for a string.

let pattern = [Desktop *] | path join
glob $pattern

@sholderbach sholderbach added 🐛 bug Something isn't working inconsistent-behavior Behavior between different commands or types inconsistent/unexpected glob-expansion Specific behavior around file-system globbing with regular commands or `glob` labels May 2, 2024
@WindSoilder WindSoilder added the good first issue Good for newcomers label May 7, 2024
@FulecoRafa
Copy link

Hello, first time contributing and I would like to work on this issue

@equt
Copy link

equt commented May 30, 2024

Maybe we could first update the doc to reflect this, as the doc currently states this as an example to show the glob type is the first class object.

@fdncred
Copy link
Collaborator

fdncred commented May 30, 2024

Maybe we could first update the doc to reflect this, as the doc currently states this as an example to show the glob type is the first class object.

Agreed. That should be ls $g instead of glob $g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working glob-expansion Specific behavior around file-system globbing with regular commands or `glob` good first issue Good for newcomers inconsistent-behavior Behavior between different commands or types inconsistent/unexpected needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

No branches or pull requests

6 participants