diff&cmp not suitable to be called as library functions.

Open
#280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reviewing diff.rs and cmp.rs, then inspect the top-level main function and the linked fix commit for the current ExitCode and exit() behavior. Check how tests are organized and add coverage for error returns without process termination. Done means both commands remain buildable while library callers receive appropriate i32 results and only the top-level main handles process exit.

Written by the indexing model from the issue text.

Description

Problems with using diffutils.rs as a library:

  1. ExitCode is intended to be consumed only by the standard library ... For forwards compatibility with potentially unusual targets, this type currently does not provide Eq, Hash, or access to the raw value. ... so it seems library callers (such as myself) would prefer an i32.
  2. The exit(2) is worrying for library callers who don't want to be suddenly killed.

I got the hy3 model to create a fix for this for me. But it lumped it all into one big commit: https://github.com/gmatht/diffutils/commit/4bdd5219adf1485aaf60114ba10adf7e3a26ac7e

Should I make a pull request including two commits:

  1. Replace the ExitCode/exit() convention with i32 returns, everywhere except at the very top main function.
  2. Add Tests that ensure errors return an appropriate i32 instead of aborting the whole process.

Also should 1./2. be split into updating diff.rs and updating cmp.rs, resulting in 4 commits? If so, main should also should still be updated in each commit so e.g. it doesn't break the build.

Do you prefer that the test or the fix be commited first?

Dominant language
Rust
Stars
276
Forks
39
Avg merge
3h 27m
Merged PRs (30d)
3

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.

More from uutils/diffutils

All issues in uutils/diffutils

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.