nushell / nushell/nushell

Missing documentation on when quotes are / are not preserved for an argument

Open
#6,577 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:quoting-expansion
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

see https://github.com/nushell/nushell/issues/6577#issuecomment-1250241095 for current state

Old stuff
ls, rm... have a, inconsistent behavior depending on how the file path is provided, event though is strictly equivalent from the point of view of the user.
The use case that led to this observation was to pass a file between quotes (spaces in path, multi platform).

How to reproduce

first define a variable containing the string of a file path (file must exist), the second line show the result of creating the string with quotes:

> let x = "/home/mmunoz/MMU/TEMP/somefile.txt"
> print $"\"($x)\""
"/home/mmunoz/MMU/TEMP/somefile.txt"

now, with ls (but rm acts the same, for example), for the user the three invocations are the "same", but one fails :

> ls "/home/mmunoz/MMU/TEMP/somefile.txt"
╭───┬────────────────────────────────────┬──────┬──────┬────────────────╮
│ # │                name                │ type │ size │    modified    │
├───┼────────────────────────────────────┼──────┼──────┼────────────────┤
│ 0 │ /home/mmunoz/MMU/TEMP/somefile.txt │ file │  0 B │ 11 minutes ago │
╰───┴────────────────────────────────────┴──────┴──────┴────────────────╯
> ls $x
╭───┬────────────────────────────────────┬──────┬──────┬──────────────╮
│ # │                name                │ type │ size │   modified   │
├───┼────────────────────────────────────┼──────┼──────┼──────────────┤
│ 0 │ /home/mmunoz/MMU/TEMP/somefile.txt │ file │  0 B │ a minute ago │
╰───┴────────────────────────────────────┴──────┴──────┴──────────────╯
> ls $"\"($x)\""
Error: nu::shell::directory_not_found (link)

  × Directory not found
   ╭─[entry #60:1:1]
 1 │ ls $"\"($x)\""
   ·    ─────┬─────
   ·         ╰── directory not found
   ╰────
Expected behavior

The last case should not fail, it is a pretty standard use for "quoting" a file path with spaces and have a uniform processing across OSes.

Screenshots

No response

Configuration

linux
nushell 0.68.1

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked issue comment and reproduce the three ls invocations from the report to compare how quoted arguments are handled. Find the appropriate Nushell documentation entry point, document when quotes are preserved or treated as part of an argument, and include the file-path example so the behavior is clear across platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.