`ls` behavior with glob patterns is surprising
When given a glob pattern as argument, ls will behave in the exact same way as glob, listing the paths themselves instead of the content of any directories.
Suppose I have two directories, foo-1 and foo-2, both of which have a empty.txt in them. Compare:
> ls foo-1 foo-2
╭───┬─────────────────┬──────┬──────┬──────────╮
│ # │ name │ type │ size │ modified │
├───┼─────────────────┼──────┼──────┼──────────┤
│ 0 │ foo-1\empty.txt │ file │ 0 B │ now │
│ 1 │ foo-2\empty.txt │ file │ 0 B │ now │
╰───┴─────────────────┴──────┴──────┴──────────╯
> ls foo*
╭───┬───────┬──────┬──────┬──────────╮
│ # │ name │ type │ size │ modified │
├───┼───────┼──────┼──────┼──────────┤
│ 0 │ foo-1 │ dir │ 0 B │ now │
│ 1 │ foo-2 │ dir │ 0 B │ now │
╰───┴───────┴──────┴──────┴──────────╯
This is surprising. I would expect the output of these two commands to be the same.
For reference, here's how ^ls works:
> ^ls foo-1 foo-2
foo-1:
empty.txt
foo-2:
empty.txt
> ^ls foo*
foo-1:
empty.txt
foo-2:
empty.txt
We can discuss whether it's better to group the output (like ^ls) or merge the output (like ls foo-1 foo-2), but I don't think it's right to list the directories themselves instead of their content.
I originally thought that they should both work like ls foo* works now, but now I'm not sure what "right" is. Seems like if you wanted to list what was inside the folder you'd do ls foo*/*.
What do you think @WindSoilder?
I have played with bash and fish, what they do for ls foo* is like:
- find all files which starts with foo
- then lists all these files, if it's a directory, then list files inside that directory.
So yeah it behaves like ls foo*/* in nushell
This may be related to ls ** only recursively listing folders, requiring ls **/* to recursively list files
Issue #12046 also has relavent discussion.