Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implemented initial version of whereis#287

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
spud0 wants to merge15 commits intouutils:main
base:main
Choose a base branch
Loading
fromspud0:main

Conversation

spud0
Copy link

This PR focuses on basic functionality of the whereis utility.

Current Issues with the current implementation:

  • The order of the output doesn't exactly match the original whereis C utility.
  • I am not sure how to handle errors inWhDirList::add_sub_dirs
  • How would I make the tests cover more cases?
  • Could there be some use of a shell script to compare the output of the original commands with the re-implemented commands to check for correctness?

Future work could include:

  • Improving matching for partial results, and clearing up some issues in theuu_app function where naming is concerned.

I am happy to iterate further based on feedback!

assert!(stdout.contains("/usr/bin/gcc"));

assert!(stdout.contains("/usr/lib/gcc"));
assert!(stdout.contains("/usr/share/gcc"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This assert fails on my machine as there is no such folder.


// Store the metadata for a file
#[derive(Serialize, Clone, Debug)]
pub struct WhDir {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What doesWh mean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The Wh is taken from the C source code. I suspect it just means WhereisDirectory since in the C source the list of paths is hardcoded. I think its there for significance of the paths that are used.https://github.com/util-linux/util-linux/blob/master/misc-utils/whereis.c

On Line 94 is the definition of the structure.

@sylvestresylvestre requested a review fromCopilotApril 22, 2025 08:24
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR implements the initial version of the whereis utility with basic functionality to locate binaries, source, and man pages.

  • Basic implementation of whereis including tests and documentation
  • Addition of test cases for various lookup options (binary, man, source)
  • Updates to Cargo.toml files to include whereis in the workspace

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
tests/tests.rsAdded mod inclusion for test_whereis in tests
tests/by-util/test_whereis.rsAdded several tests to verify whereis output
src/uu/whereis/whereis.mdAdded documentation for the whereis utility
src/uu/whereis/src/main.rsBootstraps the whereis utility using uucore macro
src/uu/whereis/src/constants.rsDefines constant arrays for directories used by whereis
src/uu/whereis/Cargo.tomlDefines the Cargo package for the whereis utility
Cargo.tomlUpdated workspace dependencies to include whereis

.arg("-s")
.arg("dig")
.succeeds()
.stdout_contains("");
Copy link
Preview

CopilotAIApr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The assertion in the test_src_only test is ineffective because checking for an empty string always passes. Consider verifying against an expected output or removing the check if it is not necessary.

Suggested change
.stdout_contains("");
.stdout_is("");

Copilot uses AI. Check for mistakes.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@cakebakercakebakercakebaker left review comments

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@spud0@cakebaker

[8]ページ先頭

©2009-2025 Movatter.jp