Skip to content

Add documentation on find command for Unix newcomers#390

Open
theNerd247 wants to merge 1 commit into
Gabriella439:mainfrom
theNerd247:master
Open

Add documentation on find command for Unix newcomers#390
theNerd247 wants to merge 1 commit into
Gabriella439:mainfrom
theNerd247:master

Conversation

@theNerd247

Copy link
Copy Markdown

No description provided.

Comment thread src/Turtle/Prelude.hs
--
-- > find "foo.txt" "./bar"
--
-- will return only a single filepath: @./bar/foo.txt@. To search for a

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Are you sure this is correct? Wouldn't you need to search for the exact string "./bar/foo.txt" to match that path?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh your right! It was originally find "foo.txt" "." and then I went back and updated.

Comment thread src/Turtle/Prelude.hs
-- will return only a single filepath: @./bar/foo.txt@. To search for a
-- filename in a similar manner to GNU find do something similar to:
--
-- > find (suffix $ "/" *> "foo.txt") "./bar"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is the "/" for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The "/" is the file separator for a file path. The intent is to match against ./bar/foo.txt so suffix would match the ./bar then "/" then the file name. I realize though that if one were to have "." as the search-tree root then immediate children ("./foo.txt") wouldn't match. It might have been better to have something like basename "foo.txt" :: Pattern FilePath"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The only reason I asked is because find still returns the full name of the path, so I think the closer match to find would be something like:

find (chars <> "/" <> "foo.txt")

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants