uutils / uutils/coreutils

`cp`: add argument index to errors

Open
#5,546 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

U - cp
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Talking to the nushell people, they might need to know which argument was the cause of the error. I think this could just be some index of the argument. So if we call:

cp -r a b c

and there would be some error with b/some/file then we would add the index 1 (0-indexed and we only count positional arguments) to the error.

The idea is that nushell could pass absolute paths to uutils (e.g. /some/absolute/path/to/b) and then if we give some error containing that path, they could trim the start out again.

It's worth exploring how difficult this would be to implement. Ideally, for nushell, it would be part of our 0.0.24 release. Other ideas for how we could get pretty errors but still use absolute paths are very welcome!

cc @fdncred

Related to: https://github.com/nushell/nushell/issues/10832, https://github.com/nushell/nushell/pull/10843

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 by tracing the Rust implementation of cp from positional-argument parsing to its error paths, then review the linked Nushell issue and pull request for integration expectations. No repository files or tests are named; done means establishing the 0-based positional-argument convention and covering the cp -r a b c case described here.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.